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]):
|
||||
filled_content = self._fill_keys(content)
|
||||
|
||||
self._tex_source_root = Path(filled_content[YAML_TEX_SOURCE_ROOT])
|
||||
self._pytex_source_root = Path(filled_content[YAML_PYTEX_SOURCE_ROOT])
|
||||
self._build_root = Path(filled_content[YAML_BUILD_ROOT])
|
||||
self._doc_root = Path(filled_content[YAML_DOC_ROOT])
|
||||
self._wrapper_dir = Path(filled_content[YAML_WRAPPER_DIR])
|
||||
self._tex_source_root = Path(filled_content[YAML_TEX_SOURCE_ROOT]) \
|
||||
if filled_content[YAML_TEX_SOURCE_ROOT] else None
|
||||
self._pytex_source_root = Path(filled_content[YAML_PYTEX_SOURCE_ROOT]) \
|
||||
if filled_content[YAML_PYTEX_SOURCE_ROOT] else None
|
||||
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:
|
||||
return {
|
||||
|
|
|
@ -83,6 +83,12 @@ class PyTeXBuilder:
|
|||
raise NotImplementedError
|
||||
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
|
||||
def old_version_info(self) -> VersionInfo:
|
||||
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)
|
||||
|
||||
def _build(self) -> bool:
|
||||
self._update_config_in_input_folder()
|
||||
logger.info("Starting build")
|
||||
self._load_pytex_files() # 8ms
|
||||
logger.verbose(f"Found {len(self._pytex_files)} source files")
|
||||
|
|
|
@ -168,27 +168,25 @@ class TexFormatter(PyTeXFormatter, ABC):
|
|||
self._mode = mode
|
||||
|
||||
def _get_provides_text(self, provided_type: str) -> str:
|
||||
if self.config.has_description:
|
||||
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
|
||||
return \
|
||||
r'\Provides%s{%s}[%s - %s]' \
|
||||
% (
|
||||
provided_type,
|
||||
self.name,
|
||||
self.attribute_dict[FormatterProperty.date.value],
|
||||
self.attribute_dict[FormatterProperty.description.value]
|
||||
)
|
||||
|
||||
else:
|
||||
return \
|
||||
'\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' \
|
||||
% (
|
||||
provided_type,
|
||||
self.name,
|
||||
self.attribute_dict[FormatterProperty.date.value],
|
||||
self.config.version,
|
||||
self.config.description
|
||||
)
|
||||
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
|
||||
return \
|
||||
r'\Provides%s{%s}[%s - %s]' \
|
||||
% (
|
||||
provided_type,
|
||||
self.name,
|
||||
self.attribute_dict[FormatterProperty.date.value],
|
||||
self.attribute_dict[FormatterProperty.description.value]
|
||||
)
|
||||
else:
|
||||
return \
|
||||
'\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' \
|
||||
% (
|
||||
provided_type,
|
||||
self.name,
|
||||
self.attribute_dict[FormatterProperty.date.value],
|
||||
self.config.version,
|
||||
self.config.description
|
||||
)
|
||||
|
||||
def format_header(self):
|
||||
if self._output_file is None:
|
||||
|
|
Loading…
Reference in a new issue