diff --git a/PyTeX/format/enums.py b/PyTeX/format/enums.py index f4ac1b0..367c61d 100644 --- a/PyTeX/format/enums.py +++ b/PyTeX/format/enums.py @@ -1,5 +1,7 @@ from enum import Enum +from PyTeX.format.macros import MacroReplacementAtomIF + class NamingScheme(Enum): prepend_author = 0 @@ -54,3 +56,24 @@ class TeXFlavour(Enum): raise NotImplementedError else: return switcher[flavour] + + +class FormatterProperty(MacroReplacementAtomIF, Enum): + author = 'author' + shortauthor = 'shortauthor' + date = 'date' + year = 'year' + version = 'version', + source_file_name = 'source_file_name' + name = 'name' # class or package name + repo_version = 'repo_version' + pytex_version = 'pytex_version' + + +class Argument(MacroReplacementAtomIF, Enum): + one = 1 + two = 2 + three = 3 + four = 4 + five = 5 + six = 6 \ No newline at end of file diff --git a/PyTeX/format/macros.py b/PyTeX/format/macros.py index 70c4c4e..8af2455 100644 --- a/PyTeX/format/macros.py +++ b/PyTeX/format/macros.py @@ -1,35 +1,14 @@ import re -from enum import Enum from typing import List, Union from .constants import * +from .enums import FormatterProperty, Argument class MacroReplacementAtomIF: pass -class FormatterProperty(MacroReplacementAtomIF, Enum): - author = 'author' - shortauthor = 'shortauthor' - date = 'date' - year = 'year' - version = 'version', - file_name = 'file_name' - name = 'name' # class or package name - repo_version = 'repo_version' - pytex_version = 'pytex_version' - - -class Argument(MacroReplacementAtomIF, Enum): - one = 1 - two = 2 - three = 3 - four = 4 - five = 5 - six = 6 - - class MacroReplacement: def __init__( self, diff --git a/PyTeX/format/pytex_formatter.py b/PyTeX/format/pytex_formatter.py index 1d9267f..e278285 100644 --- a/PyTeX/format/pytex_formatter.py +++ b/PyTeX/format/pytex_formatter.py @@ -4,17 +4,18 @@ from typing import Optional from .constants import * from .formatterif import FormatterIF -from .formatting_config import FormattingConfig +from .formatting_config import FormattingConfig, GitVersionInfo from .generic_text import GenericText from ..logger import logger from abc import ABC - +from .enums import * class PyTeXFormatter(FormatterIF, ABC): def __init__( self, input_file: Optional[Path] = None, config: Optional[FormattingConfig] = None, + git_version_info: Optional[GitVersionInfo] = None, locate_file_config: bool = True, allow_infile_config: bool = True ): @@ -23,7 +24,8 @@ class PyTeXFormatter(FormatterIF, ABC): config=config ) self._config: Optional[FormattingConfig] = self._config # for type-hinting - self._allow_infile_config = allow_infile_config + self._git_version_info: Optional[GitVersionInfo] = git_version_info + self._allow_infile_config: bool = allow_infile_config self._header: Optional[GenericText] = None if locate_file_config: file_config = self.parse_file_config() @@ -117,6 +119,17 @@ class PyTeXFormatter(FormatterIF, ABC): return self._header + @property + def attribute_dict(self) -> Dict: + return { + FormatterProperty.author.value: self.config.author, + FormatterProperty.shortauthor.value: '', + FormatterProperty.version.value: self.config.version, + FormatterProperty.source_file_name.value: self._input_file.name, + FormatterProperty.name.value: '', + } + # TODO + def make_header(self, **kwargs) -> str: return '\n'.join( [