34 lines
866 B
Python
34 lines
866 B
Python
from pathlib import Path
|
|
from enum import Enum
|
|
from PyTeX.config.global_config import GlobalPyTeXConfig
|
|
|
|
|
|
class PyTeXRootDir(Enum):
|
|
BUILD = 1
|
|
SOURCE = 2
|
|
DOC = 3
|
|
TEX = 4
|
|
|
|
|
|
class RelativePath:
|
|
def __init__(self, path: Path):
|
|
self._path: Path = path
|
|
|
|
@property
|
|
def path(self) -> Path:
|
|
return self._path
|
|
|
|
def absolute_path(self, pytex_root_dir: PyTeXRootDir) -> Path:
|
|
root: Path = {
|
|
PyTeXRootDir.BUILD: GlobalPyTeXConfig.build_root(),
|
|
PyTeXRootDir.SOURCE: GlobalPyTeXConfig.source_root(),
|
|
PyTeXRootDir.DOC: GlobalPyTeXConfig.doc_root(),
|
|
PyTeXRootDir.TEX: GlobalPyTeXConfig.tex_root()
|
|
}[pytex_root_dir]
|
|
return root / self._path
|
|
|
|
def __eq__(self, other):
|
|
return self.path == other.path
|
|
|
|
def __str__(self):
|
|
return str(self.path)
|