fix parsing tex type and flavour
This commit is contained in:
parent
5a5f0ef1e4
commit
c04897c26c
4 changed files with 16 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
from enum import Enum
|
||||
|
||||
from PyTeX.format.macros import MacroReplacementAtomIF
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class NamingScheme(Enum):
|
||||
|
@ -16,7 +16,9 @@ class TeXType(Enum):
|
|||
TeXDocumentation = 'TeXDocumentation'
|
||||
|
||||
@staticmethod
|
||||
def parse(tex_type: str):
|
||||
def parse(tex_type: str) -> Optional[TeXType]:
|
||||
if tex_type is None:
|
||||
return None
|
||||
switcher = {
|
||||
'package': TeXType.TeXPackage,
|
||||
'sty': TeXType.TeXPackage,
|
||||
|
@ -42,7 +44,9 @@ class TeXFlavour(Enum):
|
|||
LaTeX3 = 'LaTeX3'
|
||||
|
||||
@staticmethod
|
||||
def parse(flavour: str):
|
||||
def parse(flavour: str) -> Optional[TeXFlavour]:
|
||||
if flavour is None:
|
||||
return None
|
||||
switcher = {
|
||||
'1': TeXFlavour.TeX,
|
||||
'2': TeXFlavour.LaTeX2e,
|
||||
|
@ -50,6 +54,7 @@ class TeXFlavour(Enum):
|
|||
'3': TeXFlavour.LaTeX3,
|
||||
'TeX': TeXFlavour.TeX,
|
||||
'LaTeX2e': TeXFlavour.LaTeX2e,
|
||||
'LaTeX2': TeXFlavour.LaTeX2e,
|
||||
'LateX3': TeXFlavour.LaTeX3
|
||||
}
|
||||
if flavour not in switcher.keys():
|
||||
|
@ -58,6 +63,10 @@ class TeXFlavour(Enum):
|
|||
return switcher[flavour]
|
||||
|
||||
|
||||
class MacroReplacementAtomIF:
|
||||
pass
|
||||
|
||||
|
||||
class FormatterProperty(MacroReplacementAtomIF, Enum):
|
||||
author = 'author'
|
||||
shortauthor = 'shortauthor'
|
||||
|
|
|
@ -89,8 +89,8 @@ class FormattingConfig(Config):
|
|||
info = filled_content[YAML_INFO]
|
||||
self._author = info[YAML_AUTHOR]
|
||||
self._naming_scheme = info[YAML_NAMING_SCHEME]
|
||||
self._tex_flavour = info[YAML_TEX_FLAVOUR]
|
||||
self._tex_type = info[YAML_TEX_TYPE]
|
||||
self._tex_flavour = TeXFlavour.parse(info[YAML_TEX_FLAVOUR])
|
||||
self._tex_type = TeXType.parse(info[YAML_TEX_TYPE])
|
||||
self._description = info[YAML_DESCRIPTION]
|
||||
self._version = info[YAML_VERSION]
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@ from .constants import *
|
|||
from .enums import FormatterProperty, Argument
|
||||
|
||||
|
||||
class MacroReplacementAtomIF:
|
||||
pass
|
||||
|
||||
|
||||
class MacroReplacement:
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import re
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import Optional, Dict
|
||||
|
||||
from .constants import *
|
||||
from .formatterif import FormatterIF
|
||||
|
|
Loading…
Reference in a new issue