make pytex file more flexible

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

View file

@ -3,12 +3,18 @@ from pathlib import Path
from .enums import PyTeXFileType from .enums import PyTeXFileType
from PyTeX.format.formatterif import FormatterIF from PyTeX.format.formatterif import FormatterIF
from PyTeX.build.paths import RelativePath from PyTeX.build.paths import RelativePath
from ...format.enums import TeXType
class PyTeXSourceFile: class PyTeXSourceFile:
def __init__(self): def __init__(
self._pytex_file_type: PyTeXFileType = None self,
relative_path: RelativePath,
formatter: Optional[FormatterIF] = None,
pytex_file_type: Optional[PyTeXFileType] = None
):
self._relative_path: RelativePath = None self._relative_path: RelativePath = None
self._pytex_file_type: PyTeXFileType = None
self._formatter: FormatterIF = None self._formatter: FormatterIF = None
@property @property
@ -28,6 +34,14 @@ class PyTeXSourceFile:
] ]
return files return files
@property
def formatter(self) -> FormatterIF:
return self._formatter
@formatter.setter
def formatter(self, formatter):
self._formatter = formatter
def format(self, target_root: Union[Path, RelativePath]) -> Optional[List[Tuple[RelativePath, Dict]]]: def format(self, target_root: Union[Path, RelativePath]) -> Optional[List[Tuple[RelativePath, Dict]]]:
try: try:
configs = self._formatter.format( configs = self._formatter.format(