adapt usage of macros to new attribute dict

This commit is contained in:
Maximilian Keßler 2022-02-09 15:46:10 +01:00
parent 5c244f2680
commit b4526f5d0c
3 changed files with 15 additions and 1 deletions

View file

@ -74,6 +74,7 @@ class FormatterProperty(MacroReplacementAtomIF, Enum):
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'

View file

@ -23,7 +23,7 @@ class MacroReplacement:
for arg in self.args:
if type(arg) == FormatterProperty:
try:
new_args.append(getattr(formatter, arg.value))
new_args.append(formatter.attribute_dict[arg.value])
except:
raise NotImplementedError
elif type(arg) == Argument:

View file

@ -151,6 +151,7 @@ class PyTeXFormatter(FormatterIF, ABC):
FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty,
FormatterProperty.tex_type.value: str(self.config.tex_type),
FormatterProperty.tex_flavour.value: str(self.config.tex_flavour),
FormatterProperty.file_prefix.value: str(self.file_prefix)
}
@property
@ -175,6 +176,18 @@ class PyTeXFormatter(FormatterIF, ABC):
else:
return parts[0]
@property
def file_prefix(self) -> str:
if self.config.naming_scheme == NamingScheme.prepend_author:
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
return self.shortauthor + '@' + self.raw_name
elif self.config.tex_flavour == TeXFlavour.LaTeX3:
return self.shortauthor + '_' + self.raw_name
else:
raise NotImplementedError
else:
return self.raw_name
@property
def name(self):
if self.config.naming_scheme == NamingScheme.prepend_author: