add root dir to pytex builder

This commit is contained in:
Maximilian Keßler 2022-02-07 19:00:25 +01:00
parent 94b5f28567
commit e68fcb6550
2 changed files with 13 additions and 8 deletions

View file

@ -1,7 +1,6 @@
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional, Union
from PyTeX.build.build import BuildDirConfig
from PyTeX.build.enums import PyTeXRootDirType from PyTeX.build.enums import PyTeXRootDirType
from .pytex_config import PyTeXConfig from .pytex_config import PyTeXConfig
from ...logger import logger from ...logger import logger
@ -10,11 +9,18 @@ from ...logger import logger
class PyTeXBuilder: class PyTeXBuilder:
def __init__( def __init__(
self, self,
build_dir_spec: BuildDirConfig pytex_config: Optional[Union[PyTeXConfig, Path, str]] = None,
root_dir: Optional[Path] = None
): ):
self._build_target_type: Optional[PyTeXRootDirType] = None self._build_target_type: Optional[PyTeXRootDirType] = None
self._pytex_config: Optional[PyTeXConfig] = None if isinstance(pytex_config, Path) or isinstance(pytex_config, str):
config_file = Path(pytex_config)
self._pytex_config = PyTeXConfig.from_yaml(config_file)
self._root_dir: Optional[Path] = config_file.parent
else:
self._pytex_config: Optional[PyTeXConfig] = pytex_config
self._root_dir: Optional[Path] = root_dir
def build_tex_sources(self): def build_tex_sources(self):
self._build_target_type = PyTeXRootDirType.TEX_SOURCE self._build_target_type = PyTeXRootDirType.TEX_SOURCE

View file

@ -14,10 +14,6 @@ spec = BuildDirConfig(
wrapper_dir=Path('mkessler') wrapper_dir=Path('mkessler')
) )
builder = PyTeXBuilder(
build_dir_spec=spec
)
p: RelativePath = RelativePath(Path('src'), 'src/hello/bla') p: RelativePath = RelativePath(Path('src'), 'src/hello/bla')
rel = p.relative_path rel = p.relative_path
@ -52,4 +48,7 @@ conf_path = Path('/home/maximilian/git/LatexPackages/.pytexrc')
pytex_config = PyTeXConfig.from_yaml(conf_path) pytex_config = PyTeXConfig.from_yaml(conf_path)
builder = PyTeXBuilder(conf_path)
pass pass