71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
from pathlib import Path, PurePath
|
|
from typing import Optional
|
|
from PyTeX.format.formatting_config import FormattingConfig
|
|
|
|
from ..enums import PyTeXRootDirType
|
|
|
|
|
|
class GlobalPyTeXConfig:
|
|
_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
|
|
|
|
_default_formatting_config: Optional[FormattingConfig] = None
|
|
|
|
_recursive: bool = True
|
|
_overwrite_existing_files: bool = False
|
|
_clean_old_files: True
|
|
|
|
_allow_dirty: bool = False
|
|
|
|
_build_target: PyTeXRootDirType = None
|
|
|
|
@classmethod
|
|
def init(
|
|
cls,
|
|
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
|
|
):
|
|
cls._source_root = source_root
|
|
cls._build_root = build_root
|
|
cls._doc_root = doc_root
|
|
cls._tex_root = tex_root
|
|
cls._wrapper_dir = wrapper_dir
|
|
|
|
@classmethod
|
|
def build_root(cls) -> Path:
|
|
return cls._build_root
|
|
|
|
@classmethod
|
|
def doc_root(cls) -> Path:
|
|
return cls._doc_root
|
|
|
|
@classmethod
|
|
def source_root(cls) -> Path:
|
|
return cls._source_root
|
|
|
|
@classmethod
|
|
def tex_root(cls) -> Path:
|
|
return cls._tex_root
|
|
|
|
@classmethod
|
|
def wrapper_dir(cls) -> PurePath:
|
|
raise NotImplementedError
|
|
|
|
@classmethod
|
|
def build_mode(cls) -> PyTeXRootDirType:
|
|
return cls._build_target
|
|
|
|
@classmethod
|
|
def target_root(cls) -> Path:
|
|
return {
|
|
PyTeXRootDirType.BUILD: cls.build_root(),
|
|
PyTeXRootDirType.DOC: cls.doc_root(),
|
|
PyTeXRootDirType.TEX_SOURCE: cls.tex_root(),
|
|
PyTeXRootDirType.PYTEX_SOURCE: cls.source_root()
|
|
}[cls._build_target]
|