From c6b9bb6a77397b5ce962edd252c53841b5f716a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 4 Feb 2022 21:14:40 +0100 Subject: [PATCH] add pytex files --- PyTeX/build/pytex_file/__init__.py | 2 + PyTeX/build/pytex_file/enums.py | 58 ++++++++++++++++++++++++++++ PyTeX/build/pytex_file/pytex_file.py | 28 ++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 PyTeX/build/pytex_file/__init__.py create mode 100644 PyTeX/build/pytex_file/enums.py create mode 100644 PyTeX/build/pytex_file/pytex_file.py diff --git a/PyTeX/build/pytex_file/__init__.py b/PyTeX/build/pytex_file/__init__.py new file mode 100644 index 0000000..825b19e --- /dev/null +++ b/PyTeX/build/pytex_file/__init__.py @@ -0,0 +1,2 @@ +from .enums import * +from .pytex_file import PyTeXSourceFile diff --git a/PyTeX/build/pytex_file/enums.py b/PyTeX/build/pytex_file/enums.py new file mode 100644 index 0000000..f3773ea --- /dev/null +++ b/PyTeX/build/pytex_file/enums.py @@ -0,0 +1,58 @@ +from enum import Enum + + +class TeXType(Enum): + TeXPackage = 'TeXPackage' + TeXClass = 'TeXClass' + TeXDocstrip = 'TeXDocstrip' + TeXDictionary = 'TeXDictionary' + TeXDocumentation = 'TeXDocumentation' + + @staticmethod + def parse(tex_type: str): + switcher = { + 'package': TeXType.TeXPackage, + 'sty': TeXType.TeXPackage, + 'class': TeXType.TeXClass, + 'cls': TeXType.TeXClass, + 'dictionary': TeXType.TeXDictionary, + 'dict': TeXType.TeXDictionary, + 'documentation': TeXType.TeXDocumentation, + 'doc': TeXType.TeXDocumentation, # TODO: dangerous? + 'dtx': TeXType.TeXDocstrip, + 'docstrip': TeXType.TeXDocstrip, + 'strip': TeXType.TeXDocstrip + } + if tex_type not in switcher.keys(): + raise ValueError # TODO + else: + return switcher[tex_type] + + +class TeXFlavour(Enum): + TeX = 'TeX' + LaTeX2e = 'LaTeX2e' + LaTeX3 = 'LaTeX3' + + @staticmethod + def parse(flavour: str): + switcher = { + '1': TeXFlavour.TeX, + '2': TeXFlavour.LaTeX2e, + '2e': TeXFlavour.LaTeX2e, + '3': TeXFlavour.LaTeX3, + 'TeX': TeXFlavour.TeX, + 'LaTeX2e': TeXFlavour.LaTeX2e, + 'LateX3': TeXFlavour.LaTeX3 + } + if flavour not in switcher.keys(): + raise ValueError # TODO + else: + return switcher[flavour] + + +class PyTeXFileType(Enum): + PyTeXSourceFile = 'PyTeXSourceFile' + TeXSourceFile = 'TeXSourceFile' + TeXOutputFile = 'TeXOutputFile' + TeXDocumentationFile = 'TeXDocumentationFile' diff --git a/PyTeX/build/pytex_file/pytex_file.py b/PyTeX/build/pytex_file/pytex_file.py new file mode 100644 index 0000000..40a016d --- /dev/null +++ b/PyTeX/build/pytex_file/pytex_file.py @@ -0,0 +1,28 @@ +from typing import Optional, List + +from PyTeX.build.build_info import BasicBuildInfo +from PyTeX.config import BasicFormattingConfig, GlobalPyTeXConfig +from PyTeX.paths import RelativePath +from .enums import PyTeXFileType + + +class PyTeXSourceFile: + def __init__(self): + self._pytex_file_type: PyTeXFileType = None + self._relative_path: RelativePath = None + self._build_info: Optional[BasicBuildInfo] = None + + @property + def relative_path(self) -> RelativePath: + return self._relative_path + + @property + def pytex_file_type(self) -> PyTeXFileType: + return self._pytex_file_type + + def format(self) -> None: + pass + + @property + def provided_files(self) -> List[RelativePath]: + pass