make pytex file more flexible

This commit is contained in:
Maximilian Keßler 2022-02-06 20:38:30 +01:00
parent d6b9f95efb
commit 4928694212

View file

@ -1,8 +1,6 @@
from pathlib import Path, PurePath
from typing import Optional
from ..enums import PyTeXRootDirType
class BuildDirSpecification:
def __init__(
@ -13,41 +11,45 @@ class BuildDirSpecification:
tex_root: Optional[Path] = None,
wrapper_dir: Optional[PurePath] = None
):
self._source_root: Optional[Path] = source_root
self._pytex_source_root: Optional[Path] = source_root
self._build_root: Optional[Path] = build_root
self._doc_root: Optional[Path] = doc_root
self._tex_root: Optional[Path] = tex_root
self._wrapper_dir: Optional[PurePath] = wrapper_dir
self._build_target_dir_type: PyTeXRootDirType = None
@property
def build_root(self) -> Path:
if self._build_root is None:
return Path('build')
else:
return self._build_root
@property
def doc_root(self) -> Path:
if self._doc_root is None:
return Path('build/doc')
else:
return self._doc_root
@property
def source_root(self) -> Path:
return self._source_root
def pytex_source_root(self) -> Path:
if self._pytex_source_root is None:
return Path('src')
else:
return self._pytex_source_root
@property
def tex_root(self) -> Path:
def tex_source_root(self) -> Path:
if self._tex_root is None:
return Path('build/source')
else:
return self._tex_root
@property
def target_root(self) -> Path:
return {
PyTeXRootDirType.BUILD: self.build_root,
PyTeXRootDirType.DOC: self.doc_root,
PyTeXRootDirType.TEX_SOURCE: self.tex_root,
PyTeXRootDirType.PYTEX_SOURCE: self.source_root
}[self._build_target_dir_type]
@property
def wrapper_dir(self) -> PurePath:
raise NotImplementedError
if self._wrapper_dir is None:
return Path('')
else:
return self._wrapper_dir