from __future__ import annotations from enum import Enum from typing import Optional class FormatterMode(Enum): normal = 0 drop = 1 macrocode = 2 macrocode_drop = 3 class NamingScheme(Enum): prepend_author = 'prepend_author' clean = 'clean' @staticmethod def parse(naming_scheme: str) -> Optional[NamingScheme]: if naming_scheme is None: return None switcher = { 'prepend-author': NamingScheme.prepend_author, 'prepend author': NamingScheme.prepend_author, 'author': NamingScheme.prepend_author, 'clean': NamingScheme.clean, 'raw': NamingScheme.clean } if not naming_scheme in switcher.keys(): raise NotImplementedError else: return switcher[naming_scheme] class TeXType(Enum): TeXPackage = 'package' TeXClass = 'class' TeXDocstrip = 'docstrip file' TeXDictionary = 'dictionary' TeXDocumentation = 'documentation' @staticmethod def parse(tex_type: str) -> Optional[TeXType]: if tex_type is None: return None 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 NotImplementedError else: return switcher[tex_type] class TeXFlavour(Enum): TeX = 'TeX' LaTeX2e = 'LaTeX2e' LaTeX3 = 'LaTeX3' @staticmethod def parse(flavour: str) -> Optional[TeXFlavour]: if flavour is None: return None switcher = { '1': TeXFlavour.TeX, '2': TeXFlavour.LaTeX2e, '2e': TeXFlavour.LaTeX2e, '3': TeXFlavour.LaTeX3, 'TeX': TeXFlavour.TeX, 'LaTeX2e': TeXFlavour.LaTeX2e, 'LaTeX2': TeXFlavour.LaTeX2e, 'LateX3': TeXFlavour.LaTeX3 } if flavour not in switcher.keys(): raise NotImplementedError else: return switcher[flavour] class MacroReplacementAtomIF: pass class FormatterProperty(MacroReplacementAtomIF, Enum): author = 'author' shortauthor = 'shortauthor' date = 'date' year = 'year' raw_name = 'raw_name' # The 'raw' name of the package, without author prefix name = 'name' # class or package name file_prefix = 'file_prefix' version = 'version' file_name = 'file_name' source_file_name = 'source_file_name' repo_version = 'repo_version' repo_branch = 'repo_branch' repo_commit = 'repo_commit' repo_dirty = 'repo_dirty' pytex_version = 'pytex_version' pytex_branch = 'pytex_branch' pytex_commit = 'pytex_commit' pytex_dirty = 'pytex_dirty' tex_type = 'tex_type' tex_flavour = 'latex_flavour' description = 'description' class Argument(MacroReplacementAtomIF, Enum): one = 1 two = 2 three = 3 four = 4 five = 5 six = 6