divide config into two parts
This commit is contained in:
parent
6db991acc7
commit
97bc1fd50f
3 changed files with 36 additions and 26 deletions
|
@ -23,11 +23,16 @@ class BuildDirConfig(Config):
|
||||||
def set_from_json(self, content: Optional[Dict]):
|
def set_from_json(self, content: Optional[Dict]):
|
||||||
filled_content = self._fill_keys(content)
|
filled_content = self._fill_keys(content)
|
||||||
|
|
||||||
self._tex_source_root = Path(filled_content[YAML_TEX_SOURCE_ROOT])
|
self._tex_source_root = Path(filled_content[YAML_TEX_SOURCE_ROOT]) \
|
||||||
self._pytex_source_root = Path(filled_content[YAML_PYTEX_SOURCE_ROOT])
|
if filled_content[YAML_TEX_SOURCE_ROOT] else None
|
||||||
self._build_root = Path(filled_content[YAML_BUILD_ROOT])
|
self._pytex_source_root = Path(filled_content[YAML_PYTEX_SOURCE_ROOT]) \
|
||||||
self._doc_root = Path(filled_content[YAML_DOC_ROOT])
|
if filled_content[YAML_PYTEX_SOURCE_ROOT] else None
|
||||||
self._wrapper_dir = Path(filled_content[YAML_WRAPPER_DIR])
|
self._build_root = Path(filled_content[YAML_BUILD_ROOT]) \
|
||||||
|
if filled_content[YAML_BUILD_ROOT] else None
|
||||||
|
self._doc_root = Path(filled_content[YAML_DOC_ROOT]) \
|
||||||
|
if filled_content[YAML_DOC_ROOT] else None
|
||||||
|
self._wrapper_dir = Path(filled_content[YAML_WRAPPER_DIR]) \
|
||||||
|
if filled_content[YAML_WRAPPER_DIR] else None
|
||||||
|
|
||||||
def to_json(self) -> Dict:
|
def to_json(self) -> Dict:
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -83,6 +83,12 @@ class PyTeXBuilder:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
return self._build()
|
return self._build()
|
||||||
|
|
||||||
|
def _update_config_in_input_folder(self):
|
||||||
|
config_file = self.source_root / '.pytexrc' # TODO
|
||||||
|
if config_file.exists():
|
||||||
|
config = PyTeXConfig.from_yaml(config_file)
|
||||||
|
self._pytex_config = config.merge_with(self.pytex_config)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def old_version_info(self) -> VersionInfo:
|
def old_version_info(self) -> VersionInfo:
|
||||||
if self._old_version_info is None:
|
if self._old_version_info is None:
|
||||||
|
@ -304,6 +310,7 @@ class PyTeXBuilder:
|
||||||
self._new_version_info.dump_as_json(self.target_root / VERSION_INFO_FILE)
|
self._new_version_info.dump_as_json(self.target_root / VERSION_INFO_FILE)
|
||||||
|
|
||||||
def _build(self) -> bool:
|
def _build(self) -> bool:
|
||||||
|
self._update_config_in_input_folder()
|
||||||
logger.info("Starting build")
|
logger.info("Starting build")
|
||||||
self._load_pytex_files() # 8ms
|
self._load_pytex_files() # 8ms
|
||||||
logger.verbose(f"Found {len(self._pytex_files)} source files")
|
logger.verbose(f"Found {len(self._pytex_files)} source files")
|
||||||
|
|
|
@ -168,7 +168,6 @@ class TexFormatter(PyTeXFormatter, ABC):
|
||||||
self._mode = mode
|
self._mode = mode
|
||||||
|
|
||||||
def _get_provides_text(self, provided_type: str) -> str:
|
def _get_provides_text(self, provided_type: str) -> str:
|
||||||
if self.config.has_description:
|
|
||||||
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
|
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
|
||||||
return \
|
return \
|
||||||
r'\Provides%s{%s}[%s - %s]' \
|
r'\Provides%s{%s}[%s - %s]' \
|
||||||
|
@ -178,7 +177,6 @@ class TexFormatter(PyTeXFormatter, ABC):
|
||||||
self.attribute_dict[FormatterProperty.date.value],
|
self.attribute_dict[FormatterProperty.date.value],
|
||||||
self.attribute_dict[FormatterProperty.description.value]
|
self.attribute_dict[FormatterProperty.description.value]
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return \
|
return \
|
||||||
'\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' \
|
'\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' \
|
||||||
|
|
Loading…
Reference in a new issue