fix builder class

This commit is contained in:
Maximilian Keßler 2022-02-06 20:43:49 +01:00
parent 6d219f00fa
commit 85a32a19cc

View file

@ -5,6 +5,7 @@ from PyTeX.build.build import BuildDirSpecification
from PyTeX.build.enums import PyTeXRootDirType
from PyTeX.format.formatting_config import FormattingConfig
from ...logger import logger
from .pytex_config import PyTeXConfig
class PyTeXBuilder:
@ -14,6 +15,7 @@ class PyTeXBuilder:
):
self._build_target_type: Optional[PyTeXRootDirType] = None
self._pytex_config: Optional[PyTeXConfig] = None
def build_tex_sources(self):
self._build_target_type = PyTeXRootDirType.TEX_SOURCE
@ -32,20 +34,27 @@ class PyTeXBuilder:
raise NotImplementedError
self._build()
@property
def pytex_config(self) -> PyTeXConfig:
if self._pytex_config is None:
return PyTeXConfig()
else:
return self._pytex_config
@property
def target_root(self) -> Path:
return {
PyTeXRootDirType.BUILD: self._build_spec.build_root,
PyTeXRootDirType.DOC: self._build_spec.doc_root,
PyTeXRootDirType.TEX_SOURCE: self._build_spec.tex_source_root,
PyTeXRootDirType.BUILD: self.pytex_config.build_dir_specification.build_root,
PyTeXRootDirType.DOC: self.pytex_config.build_dir_specification.doc_root,
PyTeXRootDirType.TEX_SOURCE: self.pytex_config.build_dir_specification.tex_source_root,
}[self._build_target_type]
@property
def source_root(self) -> Path:
return {
PyTeXRootDirType.BUILD: self._build_spec.tex_source_root,
PyTeXRootDirType.DOC: self._build_spec.tex_source_root,
PyTeXRootDirType.TEX_SOURCE: self._build_spec.pytex_source_root,
PyTeXRootDirType.BUILD: self.pytex_config.build_dir_specification.tex_source_root,
PyTeXRootDirType.DOC: self.pytex_config.build_dir_specification.tex_source_root,
PyTeXRootDirType.TEX_SOURCE: self.pytex_config.build_dir_specification.pytex_source_root,
}[self._build_target_type]
def get_git_version_info(self):