Merge branch 'master' of gitlab.com:latexci/packages/PyTeX
This commit is contained in:
commit
d1806d970f
5 changed files with 40 additions and 27 deletions
|
@ -96,7 +96,8 @@ class BuildInfo:
|
||||||
or include_pytex_info_text
|
or include_pytex_info_text
|
||||||
or include_timestamp
|
or include_timestamp
|
||||||
or include_pytex_version
|
or include_pytex_version
|
||||||
or include_git_version):
|
or include_git_version
|
||||||
|
or extra_header):
|
||||||
self._header = None
|
self._header = None
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -113,7 +114,8 @@ class BuildInfo:
|
||||||
self._header += PYTEX_VERSION
|
self._header += PYTEX_VERSION
|
||||||
if include_git_version:
|
if include_git_version:
|
||||||
self._header += SOURCE_CODE_VERSION
|
self._header += SOURCE_CODE_VERSION
|
||||||
self._header += ['']
|
if len(self._header) > 0:
|
||||||
|
self._header += ['']
|
||||||
if extra_header:
|
if extra_header:
|
||||||
self._header += extra_header + ['']
|
self._header += extra_header + ['']
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class TexFileToFormat:
|
||||||
build_all: bool = False):
|
build_all: bool = False):
|
||||||
self.src_path = src_path
|
self.src_path = src_path
|
||||||
self.build_path = build_dir
|
self.build_path = build_dir
|
||||||
self.tex_name = latex_name # Still an identifier on how to name the package when being formatted
|
self.latex_name = latex_name # Still an identifier on how to name the package when being formatted
|
||||||
self.current_build_info = current_build_info
|
self.current_build_info = current_build_info
|
||||||
self.last_build_info = last_build_info
|
self.last_build_info = last_build_info
|
||||||
self.allow_dirty = allow_dirty
|
self.allow_dirty = allow_dirty
|
||||||
|
@ -68,19 +68,20 @@ class TexFileToFormat:
|
||||||
|
|
||||||
def __format_header(self):
|
def __format_header(self):
|
||||||
new_header = []
|
new_header = []
|
||||||
for line in self.current_build_info.header:
|
if self.current_build_info.header:
|
||||||
if '.pysty' in self.src_path.name:
|
for line in self.current_build_info.header:
|
||||||
latex_file_type = 'package'
|
if '.pysty' in self.src_path.name:
|
||||||
elif '.pycls' in self.src_path.name:
|
latex_file_type = 'package'
|
||||||
latex_file_type = 'class'
|
elif '.pycls' in self.src_path.name:
|
||||||
elif '.pydict' in self.src_path.name:
|
latex_file_type = 'class'
|
||||||
latex_file_type = 'dictionary'
|
elif '.pydict' in self.src_path.name:
|
||||||
else:
|
latex_file_type = 'dictionary'
|
||||||
raise Exception('Programming error. Please contact the developer.')
|
else:
|
||||||
new_header.append(line.format(
|
raise Exception('Programming error. Please contact the developer.')
|
||||||
source_file=self.src_path.name,
|
new_header.append(line.format(
|
||||||
latex_file_type=latex_file_type
|
source_file=self.src_path.name,
|
||||||
))
|
latex_file_type=latex_file_type
|
||||||
|
))
|
||||||
self._header = new_header
|
self._header = new_header
|
||||||
|
|
||||||
def __format(self) -> dict:
|
def __format(self) -> dict:
|
||||||
|
@ -90,28 +91,32 @@ class TexFileToFormat:
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
extra_header=self._header,
|
extra_header=self._header,
|
||||||
tex_version='LaTeX2e',
|
tex_version='LaTeX2e',
|
||||||
version=self.current_build_info.packages_version)
|
version=self.current_build_info.packages_version,
|
||||||
|
latex_name=self.latex_name)
|
||||||
elif self.src_path.name.endswith('.pycls'):
|
elif self.src_path.name.endswith('.pycls'):
|
||||||
formatter = ClassFormatter(
|
formatter = ClassFormatter(
|
||||||
class_name=self.src_path.with_suffix('').name,
|
class_name=self.src_path.with_suffix('').name,
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
extra_header=self._header,
|
extra_header=self._header,
|
||||||
tex_version='LaTeX2e',
|
tex_version='LaTeX2e',
|
||||||
version=self.current_build_info.packages_version)
|
version=self.current_build_info.packages_version,
|
||||||
|
latex_name=self.latex_name)
|
||||||
elif self.src_path.name.endswith('.pysty3'):
|
elif self.src_path.name.endswith('.pysty3'):
|
||||||
formatter = PackageFormatter(
|
formatter = PackageFormatter(
|
||||||
package_name=self.src_path.with_suffix('').name,
|
package_name=self.src_path.with_suffix('').name,
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
extra_header=self._header,
|
extra_header=self._header,
|
||||||
tex_version='LaTeX3',
|
tex_version='LaTeX3',
|
||||||
version=self.current_build_info.packages_version)
|
version=self.current_build_info.packages_version,
|
||||||
|
latex_name=self.latex_name)
|
||||||
elif self.src_path.name.endswith('.pycls3'):
|
elif self.src_path.name.endswith('.pycls3'):
|
||||||
formatter = ClassFormatter(
|
formatter = ClassFormatter(
|
||||||
class_name=self.src_path.with_suffix('').name,
|
class_name=self.src_path.with_suffix('').name,
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
extra_header=self._header,
|
extra_header=self._header,
|
||||||
tex_version='LaTeX3',
|
tex_version='LaTeX3',
|
||||||
version=self.current_build_info.packages_version)
|
version=self.current_build_info.packages_version,
|
||||||
|
latex_name=self.latex_name)
|
||||||
elif self.src_path.name.endswith('.pydict'):
|
elif self.src_path.name.endswith('.pydict'):
|
||||||
formatter = DictionaryFormatter(
|
formatter = DictionaryFormatter(
|
||||||
kind=self.src_path.with_suffix('').name,
|
kind=self.src_path.with_suffix('').name,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import PyTeX.macros
|
||||||
|
|
||||||
class ClassFormatter(PyTeX.formatter.TexFormatter):
|
class ClassFormatter(PyTeX.formatter.TexFormatter):
|
||||||
def __init__(self, class_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e',
|
def __init__(self, class_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e',
|
||||||
version: str = '0.0.0'):
|
version: str = '0.0.0', latex_name: str = 'prepend-author'):
|
||||||
PyTeX.formatter.TexFormatter.__init__(
|
PyTeX.formatter.TexFormatter.__init__(
|
||||||
self,
|
self,
|
||||||
name=class_name,
|
name=class_name,
|
||||||
|
@ -13,7 +13,8 @@ class ClassFormatter(PyTeX.formatter.TexFormatter):
|
||||||
header=extra_header,
|
header=extra_header,
|
||||||
file_extension='.cls',
|
file_extension='.cls',
|
||||||
tex_version=tex_version,
|
tex_version=tex_version,
|
||||||
version=version
|
version=version,
|
||||||
|
latex_name=latex_name
|
||||||
)
|
)
|
||||||
self.tex_version = tex_version
|
self.tex_version = tex_version
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import PyTeX.macros
|
||||||
|
|
||||||
class PackageFormatter(PyTeX.formatter.TexFormatter):
|
class PackageFormatter(PyTeX.formatter.TexFormatter):
|
||||||
def __init__(self, package_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e',
|
def __init__(self, package_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e',
|
||||||
version: str = '0.0.0'):
|
version: str = '0.0.0', latex_name: str = 'prepend-author'):
|
||||||
PyTeX.formatter.TexFormatter.__init__(
|
PyTeX.formatter.TexFormatter.__init__(
|
||||||
self,
|
self,
|
||||||
name=package_name,
|
name=package_name,
|
||||||
|
@ -13,7 +13,8 @@ class PackageFormatter(PyTeX.formatter.TexFormatter):
|
||||||
header=extra_header,
|
header=extra_header,
|
||||||
file_extension='.sty',
|
file_extension='.sty',
|
||||||
tex_version=tex_version,
|
tex_version=tex_version,
|
||||||
version=version
|
version=version,
|
||||||
|
latex_name=latex_name
|
||||||
)
|
)
|
||||||
self.tex_version = tex_version
|
self.tex_version = tex_version
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,12 @@ from PyTeX.base import Attributes, Args
|
||||||
|
|
||||||
class TexFormatter:
|
class TexFormatter:
|
||||||
def __init__(self, name: str, author: str, header: Optional[List[str]], file_extension: str,
|
def __init__(self, name: str, author: str, header: Optional[List[str]], file_extension: str,
|
||||||
tex_version: str, version: str):
|
tex_version: str, version: str, latex_name: str):
|
||||||
self.version = version
|
self.version = version
|
||||||
self.header = header
|
self.header = header
|
||||||
self.name_raw = name
|
self.name_raw = name
|
||||||
self.author = author
|
self.author = author
|
||||||
|
self.latex_name = latex_name
|
||||||
author_parts = self.author.lower().replace('ß', 'ss').split(' ')
|
author_parts = self.author.lower().replace('ß', 'ss').split(' ')
|
||||||
self.author_acronym = author_parts[0][0] + author_parts[-1]
|
self.author_acronym = author_parts[0][0] + author_parts[-1]
|
||||||
self.date = datetime.now().strftime('%Y/%m/%d')
|
self.date = datetime.now().strftime('%Y/%m/%d')
|
||||||
|
@ -21,8 +22,11 @@ class TexFormatter:
|
||||||
self.replace_dict: Dict = {}
|
self.replace_dict: Dict = {}
|
||||||
self.arg_replace_dict: Dict = {}
|
self.arg_replace_dict: Dict = {}
|
||||||
self.source_file_name = "not specified"
|
self.source_file_name = "not specified"
|
||||||
self.name_lowercase = r'{prefix}-{name}'.format(prefix=self.author_acronym,
|
if self.latex_name == 'prepend-author':
|
||||||
name=self.name_raw.lower().strip().replace(' ', '-'))
|
self.name_lowercase = r'{prefix}-{name}'.format(prefix=self.author_acronym,
|
||||||
|
name=self.name_raw.lower().strip().replace(' ', '-'))
|
||||||
|
else:
|
||||||
|
self.name_lowercase = self.name_raw.lower().strip().replace(' ', '-')
|
||||||
self.file_name = self.name_lowercase + file_extension
|
self.file_name = self.name_lowercase + file_extension
|
||||||
if tex_version == 'LaTeX2e':
|
if tex_version == 'LaTeX2e':
|
||||||
self.prefix = self.name_lowercase.replace('-', '@') + '@'
|
self.prefix = self.name_lowercase.replace('-', '@') + '@'
|
||||||
|
|
Loading…
Reference in a new issue