diff --git a/config.py b/config.py index 107ed73..e85f923 100644 --- a/config.py +++ b/config.py @@ -30,3 +30,12 @@ PACKAGE_INFO_TEXT = [ "Reportings of bugs, suggestions and improvements are welcome, see the README", "at the Git repository for further information." ] + +PYTEX_INFO_TEXT = [ + "This package has been generated by PyTeX, available at", + " https://github.com/kesslermaximilian/PyTeX", + "and built from source file '{source_file}'.", + "It is STRONGLY DISCOURAGED to edit this source file directly, since local changes", + "will not be versioned by Git and overwritten by the next build. Always edit the", + "source file and build the package again." +] diff --git a/enums.py b/enums.py index 16244b9..19d11ec 100644 --- a/enums.py +++ b/enums.py @@ -10,6 +10,7 @@ class Attributes(Enum): file_name = 'file_name' date = 'date' year = 'year' + source_file_name = 'source_file_name' class Args(Enum): diff --git a/package_formatter.py b/package_formatter.py index 0b2d606..f9e68b5 100644 --- a/package_formatter.py +++ b/package_formatter.py @@ -21,6 +21,7 @@ class PackageFormatter: self.year = int(datetime.now().strftime('%Y')) self.replace_dict: Dict = {} self.arg_replace_dict: Dict = {} + self.source_file_name = "not specified" @staticmethod def command_name2keyword(keyword: str): @@ -88,6 +89,7 @@ class PackageFormatter: return contents def format_package(self, input_path: Path, output_dir: Path = None): + self.source_file_name = str(input_path.name) input_file = input_path.open() lines = input_file.readlines() newlines = [] diff --git a/replacements.py b/replacements.py index 26ff9e6..8f7a188 100644 --- a/replacements.py +++ b/replacements.py @@ -1,11 +1,12 @@ from enums import Attributes, Args from package_formatter import PackageFormatter -from config import LICENSE, PACKAGE_INFO_TEXT +from config import LICENSE, PACKAGE_INFO_TEXT, PYTEX_INFO_TEXT def make_default_commands(package_formatter: PackageFormatter): - header = '%' * 80 + '\n' + '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT)) \ - + '\n' + '%' * 80 + '\n' \ + header = '%' * 80 + '\n' \ + + '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT + [''] + PYTEX_INFO_TEXT)) \ + + '\n' + '%' * 80 + '\n\n' \ + '\\NeedsTeXFormat{{LaTeX2e}}\n' \ '\\ProvidesPackage{{{package_name}}}[{date} - {description}]\n\n' package_formatter.add_arg_replacement( @@ -15,7 +16,8 @@ def make_default_commands(package_formatter: PackageFormatter): date=Attributes.date, description=Args.one, year=Attributes.year, - copyright_holders=Attributes.author + copyright_holders=Attributes.author, + source_file=Attributes.source_file_name ) package_formatter.add_replacement('package name', '{}', Attributes.package_name) package_formatter.add_replacement('package prefix', '{}', Attributes.package_prefix)