from typing import Optional, List, Dict, Tuple from PyTeX.build.build_info import BasicBuildInfo from PyTeX.build.config import GlobalPyTeXConfig from .enums import PyTeXFileType from PyTeX.format.formatter import Formatter from PyTeX.build.paths import RelativePath class PyTeXSourceFile: def __init__(self): self._pytex_file_type: PyTeXFileType = None self._relative_path: RelativePath = None self._formatter: Formatter = None self._build_info: Optional[BasicBuildInfo] = None @property def relative_path(self): return self._relative_path @property def pytex_file_type(self) -> PyTeXFileType: return self._pytex_file_type @property def output_files(self) -> List[RelativePath]: files = self._formatter.output_files files = [ self._relative_path.with_name(filename) for filename in files ] return files def format(self) -> Optional[List[Tuple[RelativePath, Dict]]]: try: configs = self._formatter.format(GlobalPyTeXConfig.target_root()) except Exception as e: raise NotImplementedError configs = [ (self._relative_path.with_name(filename), config) for [filename, config] in configs ] return configs