2022-02-09 11:55:18 +01:00
|
|
|
from __future__ import annotations
|
2022-02-04 11:39:15 +01:00
|
|
|
from enum import Enum
|
2022-02-09 11:55:18 +01:00
|
|
|
from typing import Optional
|
2022-02-09 11:49:14 +01:00
|
|
|
|
2022-02-04 11:39:15 +01:00
|
|
|
|
2022-02-09 19:25:25 +01:00
|
|
|
class FormatterMode(Enum):
|
|
|
|
normal = 0
|
|
|
|
drop = 1
|
|
|
|
macrocode = 2
|
|
|
|
macrocode_drop = 3
|
|
|
|
|
|
|
|
|
2022-02-04 11:39:15 +01:00
|
|
|
class NamingScheme(Enum):
|
2022-02-09 17:31:06 +01:00
|
|
|
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]
|
2022-02-04 11:39:15 +01:00
|
|
|
|
|
|
|
|
2022-02-06 00:12:54 +01:00
|
|
|
class TeXType(Enum):
|
2022-02-09 15:38:01 +01:00
|
|
|
TeXPackage = 'package'
|
|
|
|
TeXClass = 'class'
|
|
|
|
TeXDocstrip = 'docstrip file'
|
|
|
|
TeXDictionary = 'dictionary'
|
|
|
|
TeXDocumentation = 'documentation'
|
2022-02-06 00:12:54 +01:00
|
|
|
|
|
|
|
@staticmethod
|
2022-02-09 11:55:18 +01:00
|
|
|
def parse(tex_type: str) -> Optional[TeXType]:
|
|
|
|
if tex_type is None:
|
|
|
|
return None
|
2022-02-06 00:12:54 +01:00
|
|
|
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
|
2022-02-09 11:55:18 +01:00
|
|
|
def parse(flavour: str) -> Optional[TeXFlavour]:
|
|
|
|
if flavour is None:
|
|
|
|
return None
|
2022-02-06 00:12:54 +01:00
|
|
|
switcher = {
|
|
|
|
'1': TeXFlavour.TeX,
|
|
|
|
'2': TeXFlavour.LaTeX2e,
|
|
|
|
'2e': TeXFlavour.LaTeX2e,
|
|
|
|
'3': TeXFlavour.LaTeX3,
|
|
|
|
'TeX': TeXFlavour.TeX,
|
|
|
|
'LaTeX2e': TeXFlavour.LaTeX2e,
|
2022-02-09 11:55:18 +01:00
|
|
|
'LaTeX2': TeXFlavour.LaTeX2e,
|
2022-02-06 00:12:54 +01:00
|
|
|
'LateX3': TeXFlavour.LaTeX3
|
|
|
|
}
|
|
|
|
if flavour not in switcher.keys():
|
|
|
|
raise NotImplementedError
|
|
|
|
else:
|
|
|
|
return switcher[flavour]
|
2022-02-09 11:49:14 +01:00
|
|
|
|
|
|
|
|
2022-02-09 11:55:18 +01:00
|
|
|
class MacroReplacementAtomIF:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-02-09 11:49:14 +01:00
|
|
|
class FormatterProperty(MacroReplacementAtomIF, Enum):
|
|
|
|
author = 'author'
|
|
|
|
shortauthor = 'shortauthor'
|
|
|
|
date = 'date'
|
|
|
|
year = 'year'
|
2022-02-09 15:38:01 +01:00
|
|
|
raw_name = 'raw_name' # The 'raw' name of the package, without author prefix
|
2022-02-09 11:49:14 +01:00
|
|
|
name = 'name' # class or package name
|
2022-02-09 15:46:10 +01:00
|
|
|
file_prefix = 'file_prefix'
|
2022-02-09 15:38:01 +01:00
|
|
|
version = 'version'
|
|
|
|
file_name = 'file_name'
|
|
|
|
source_file_name = 'source_file_name'
|
2022-02-09 11:49:14 +01:00
|
|
|
repo_version = 'repo_version'
|
2022-02-09 15:38:01 +01:00
|
|
|
repo_branch = 'repo_branch'
|
|
|
|
repo_commit = 'repo_commit'
|
|
|
|
repo_dirty = 'repo_dirty'
|
2022-02-09 11:49:14 +01:00
|
|
|
pytex_version = 'pytex_version'
|
2022-02-09 15:38:01 +01:00
|
|
|
pytex_branch = 'pytex_branch'
|
|
|
|
pytex_commit = 'pytex_commit'
|
|
|
|
pytex_dirty = 'pytex_dirty'
|
|
|
|
tex_type = 'tex_type'
|
2022-02-09 21:11:46 +01:00
|
|
|
Tex_type= 'Tex_type'
|
2022-02-09 15:38:01 +01:00
|
|
|
tex_flavour = 'latex_flavour'
|
2022-02-09 19:50:49 +01:00
|
|
|
description = 'description'
|
2022-02-09 11:49:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Argument(MacroReplacementAtomIF, Enum):
|
|
|
|
one = 1
|
|
|
|
two = 2
|
|
|
|
three = 3
|
|
|
|
four = 4
|
|
|
|
five = 5
|
2022-02-09 15:38:01 +01:00
|
|
|
six = 6
|