pytex/PyTeX/build/config/global_config.py

71 lines
1.9 KiB
Python
Raw Normal View History

2022-02-04 21:14:58 +01:00
from pathlib import Path, PurePath
2022-02-04 11:39:15 +01:00
from typing import Optional
2022-02-05 19:36:42 +01:00
from PyTeX.format.formatting_config import FormattingConfig
2022-02-04 11:39:15 +01:00
2022-02-05 19:36:42 +01:00
from ..enums import PyTeXRootDirType
2022-02-04 11:39:15 +01:00
class BuildDirSpecification:
def __init__(
self,
2022-02-04 21:14:58 +01:00
source_root: Optional[Path] = None,
build_root: Optional[Path] = None,
doc_root: Optional[Path] = None,
tex_root: Optional[Path] = None,
wrapper_dir: Optional[PurePath] = None
):
self._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:
return self._build_root
@property
def doc_root(self) -> Path:
return self._doc_root
@property
def source_root(self) -> Path:
return self._source_root
@property
def tex_root(self) -> Path:
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
class PyTeXBuilder:
def __init__(
self,
build_dir_spec: BuildDirSpecification
):
self._build_spec: BuildDirSpecification = None
self._default_formatting_config: Optional[FormattingConfig] = None
self._recursive: bool = True
self._overwrite_existing_files: bool = False
self._clean_old_files: True
self._allow_dirty: bool = False