better root dir management

This commit is contained in:
Maximilian Keßler 2022-02-08 19:40:41 +01:00
parent b00e62c017
commit 0423cb5de8

View file

@ -19,10 +19,15 @@ class PyTeXBuilder:
self._build_target_type: Optional[PyTeXRootDirType] = None self._build_target_type: Optional[PyTeXRootDirType] = None
if isinstance(pytex_config, Path) or isinstance(pytex_config, str): if isinstance(pytex_config, Path) or isinstance(pytex_config, str):
config_file = Path(pytex_config) config_file = Path(pytex_config)
self._pytex_config = PyTeXConfig.from_yaml(config_file) self._pytex_config: Optional[PyTeXConfig] = PyTeXConfig.from_yaml(config_file)
self._root_dir: Optional[Path] = config_file.parent
else: else:
self._pytex_config = pytex_config self._pytex_config = pytex_config
if root_dir is None:
if isinstance(pytex_config, Path):
self._root_dir = pytex_config.parent
else:
self._root_dir: Path = Path('.') # Working directory
else:
self._root_dir = root_dir self._root_dir = root_dir
# Non-public attributes # Non-public attributes
@ -82,10 +87,10 @@ class PyTeXBuilder:
} }
return switcher[self._build_target_type] return switcher[self._build_target_type]
def get_git_version_info(self): def _get_git_version_info(self):
pass pass
def parse_config_file(self): def _parse_config_file(self):
pass pass
@classmethod @classmethod
@ -109,7 +114,7 @@ class PyTeXBuilder:
for extension in self.supported_extensions() for extension in self.supported_extensions()
] ]
def load_pytex_files(self): def _load_pytex_files(self):
self._pytex_files = [] self._pytex_files = []
if self.pytex_config.recursive: if self.pytex_config.recursive:
files = self.source_root.rglob('*') files = self.source_root.rglob('*')
@ -131,6 +136,6 @@ class PyTeXBuilder:
def _build(self) -> bool: def _build(self) -> bool:
logger.info("Starting build") logger.info("Starting build")
self.load_pytex_files() self._load_pytex_files()
return True return True