34 lines
2 KiB
Python
34 lines
2 KiB
Python
from enums import Attributes, Args
|
|
from package_formatter import PackageFormatter
|
|
from config import LICENSE, PACKAGE_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' \
|
|
+ '\\NeedsTeXFormat{{LaTeX2e}}\n' \
|
|
'\\ProvidesPackage{{{package_name}}}[{date} - {description}]\n\n'
|
|
package_formatter.add_arg_replacement(
|
|
1, 'header',
|
|
header,
|
|
package_name=Attributes.package_name,
|
|
date=Attributes.date,
|
|
description=Args.one,
|
|
year=Attributes.year,
|
|
copyright_holders=Attributes.author
|
|
)
|
|
package_formatter.add_replacement('package name', '{}', Attributes.package_name)
|
|
package_formatter.add_replacement('package prefix', '{}', Attributes.package_prefix)
|
|
package_formatter.add_replacement('file name', '{name}', name=Attributes.file_name)
|
|
package_formatter.add_replacement('date', '{}', Attributes.date)
|
|
package_formatter.add_replacement('author', '{}', Attributes.author)
|
|
package_formatter.add_arg_replacement(1, 'newif', r'\newif\if{prefix}{condition}',
|
|
prefix=Attributes.package_prefix, condition=Args.one)
|
|
package_formatter.add_arg_replacement(2, 'setif', r'\{prefix}{condition}{value}',
|
|
prefix=Attributes.package_prefix, condition=Args.one, value=Args.two)
|
|
package_formatter.add_arg_replacement(1, 'if', r'\if{prefix}{condition}', prefix=Attributes.package_prefix,
|
|
condition=Args.one)
|
|
package_formatter.add_arg_replacement(1, 'info', r'\PackageInfo{{{name}}}{{{info}}}', name=Attributes.package_name,
|
|
info=Args.one)
|
|
package_formatter.add_arg_replacement(1, 'warning', r'\PackageWarning{{{name}}}{{{warning}}}',
|
|
name=Attributes.package_name, warning=Args.one)
|