fix some formatting issues with headers

This commit is contained in:
Maximilian Keßler 2022-02-09 16:24:02 +01:00
parent 190ff1a339
commit 1f9825e937
2 changed files with 19 additions and 13 deletions

View file

@ -65,7 +65,7 @@ class GenericText:
lines = [] lines = []
for line in self.text: for line in self.text:
try: try:
line = '% ' + line.format(**kwargs).rjust(77) + '%' line = '% ' + line.rstrip().format(**kwargs).ljust(77) + '%'
if len(line) > 80: if len(line) > 80:
logger.warning( logger.warning(
'Line too long') # TODO 'Line too long') # TODO
@ -96,7 +96,10 @@ class GenericText:
def __iadd__(self, other: Union[None, GenericText, List[str]]) -> GenericText: def __iadd__(self, other: Union[None, GenericText, List[str]]) -> GenericText:
if not self.has_value(): if not self.has_value():
self.text = other if isinstance(other, GenericText):
self.text = other.text
else:
self.text = other
elif isinstance(other, GenericText): elif isinstance(other, GenericText):
if other.has_value(): if other.has_value():
self.text += other.text self.text += other.text

View file

@ -149,9 +149,9 @@ class PyTeXFormatter(FormatterIF, ABC):
FormatterProperty.pytex_branch.value: self.git_version_info.pytex_version.branch, FormatterProperty.pytex_branch.value: self.git_version_info.pytex_version.branch,
FormatterProperty.pytex_commit.value: self.git_version_info.pytex_version.commit_hash, FormatterProperty.pytex_commit.value: self.git_version_info.pytex_version.commit_hash,
FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty, FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty,
FormatterProperty.tex_type.value: str(self.config.tex_type), FormatterProperty.tex_type.value: self.config.tex_type.value,
FormatterProperty.tex_flavour.value: str(self.config.tex_flavour), FormatterProperty.tex_flavour.value: self.config.tex_flavour.value,
FormatterProperty.file_prefix.value: str(self.file_prefix) FormatterProperty.file_prefix.value: self.file_prefix
} }
@property @property
@ -199,11 +199,14 @@ class PyTeXFormatter(FormatterIF, ABC):
return self._output_file.name return self._output_file.name
def make_header(self, **kwargs) -> str: def make_header(self, **kwargs) -> str:
return '\n'.join( try:
[ return '\n'.join(
'%' * 80, [
self.header.format(**kwargs), # TODO: add standard keywords here '%' * 80,
'%' * 80, self.header.format(**self.attribute_dict),
'' '%' * 80,
] ''
) ]
)
except KeyError:
raise NotImplementedError