use correct VersionInfo

This commit is contained in:
Maximilian Keßler 2022-02-08 19:15:26 +01:00
parent 3571d409f0
commit 4aaec9fc3d

View file

@ -5,7 +5,7 @@ from .enums import PyTeXRootDirType
from .pytex_config import PyTeXConfig
from ...logger import logger
from .constants import *
from ..versioning.version_info.version_info import FileVersionInfo
from ..versioning.version_info.version_info import VersionInfo
from .pytex_file import PyTeXSourceFile
from .relative_path import RelativePath
@ -26,36 +26,36 @@ class PyTeXBuilder:
self._root_dir = root_dir
# Non-public attributes
self._version_info: Optional[FileVersionInfo] = None
self._version_info: Optional[VersionInfo] = None
self._pytex_files: Optional[List[PyTeXSourceFile]] = None
def build_tex_sources(self):
def build_tex_sources(self) -> bool:
self._build_target_type = PyTeXRootDirType.TEX_SOURCE
self._build()
return self._build()
def build_documentation(self):
def build_documentation(self) -> bool:
self._build_target_type = PyTeXRootDirType.DOC
self._build()
return self._build()
def build_tex_files(self):
def build_tex_files(self) -> bool:
self._build_target_type = PyTeXRootDirType.BUILD
self._build()
return self._build()
def build(self):
def build(self) -> bool:
if self._build_target_type is None:
raise NotImplementedError
self._build()
return self._build()
@property
def version_info(self):
def version_info(self) -> VersionInfo:
if self._version_info is None:
version_info_file = self.target_root / VERSION_INFO_FILE
if version_info_file.exists():
self._version_info = FileVersionInfo.from_json(
self._version_info = VersionInfo.from_json(
self.target_root / VERSION_INFO_FILE
)
else:
self._version_info = FileVersionInfo()
self._version_info = VersionInfo()
return self._version_info
@property
@ -122,13 +122,15 @@ class PyTeXBuilder:
relative_path=RelativePath(
self.source_root,
file
)
),
default_config=self.pytex_config.default_formatting_config
)
)
# TODO: give pytex source file some additional building information
def _build(self):
def _build(self) -> bool:
logger.info("Starting build")
self.load_pytex_files()
return True