implement naming scheme
This commit is contained in:
parent
65d2df0aa6
commit
7a3fded422
3 changed files with 20 additions and 4 deletions
|
@ -4,8 +4,24 @@ from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
class NamingScheme(Enum):
|
class NamingScheme(Enum):
|
||||||
prepend_author = 0
|
prepend_author = 'prepend_author'
|
||||||
clean = 1
|
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):
|
class TeXType(Enum):
|
||||||
|
|
|
@ -44,7 +44,7 @@ class FormattingConfig(Config):
|
||||||
|
|
||||||
info = filled_content[YAML_INFO]
|
info = filled_content[YAML_INFO]
|
||||||
self._author = info[YAML_AUTHOR]
|
self._author = info[YAML_AUTHOR]
|
||||||
self._naming_scheme = info[YAML_NAMING_SCHEME]
|
self._naming_scheme = NamingScheme.parse(info[YAML_NAMING_SCHEME])
|
||||||
self._tex_flavour = TeXFlavour.parse(info[YAML_TEX_FLAVOUR])
|
self._tex_flavour = TeXFlavour.parse(info[YAML_TEX_FLAVOUR])
|
||||||
self._tex_type = TeXType.parse(info[YAML_TEX_TYPE])
|
self._tex_type = TeXType.parse(info[YAML_TEX_TYPE])
|
||||||
self._description = info[YAML_DESCRIPTION]
|
self._description = info[YAML_DESCRIPTION]
|
||||||
|
|
|
@ -162,7 +162,7 @@ class PyTeXFormatter(FormatterIF, ABC):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def shortauthor(self) -> str:
|
def shortauthor(self) -> str:
|
||||||
parts = self.config.author.replace('ß', 'ss').split(' ') # TODO: better non-alphanumeric handling
|
parts = self.config.author.lower().replace('ß', 'ss').split(' ') # TODO: better non-alphanumeric handling
|
||||||
if len(parts) == 1:
|
if len(parts) == 1:
|
||||||
return parts[0]
|
return parts[0]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue