optimize imports and reformat files
This commit is contained in:
parent
3dfb889728
commit
94b5f28567
24 changed files with 53 additions and 62 deletions
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path, PurePath
|
||||
from typing import Optional, Dict
|
||||
|
||||
from .constants import *
|
||||
from ...format.config import Config
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from typing import Optional
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from PyTeX.build.build import BuildDirConfig
|
||||
from PyTeX.build.enums import PyTeXRootDirType
|
||||
from ...logger import logger
|
||||
from .pytex_config import PyTeXConfig
|
||||
from ...logger import logger
|
||||
|
||||
|
||||
class PyTeXBuilder:
|
||||
|
@ -64,5 +64,3 @@ class PyTeXBuilder:
|
|||
|
||||
def _build(self):
|
||||
logger.info("Starting build")
|
||||
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ from typing import Optional, Dict
|
|||
|
||||
from PyTeX.build.build import BuildDirConfig
|
||||
from PyTeX.format.formatting_config import FormattingConfig
|
||||
from ...format.config import Config
|
||||
from .constants import *
|
||||
from ...format.config import Config
|
||||
|
||||
|
||||
class PyTeXConfig(Config):
|
||||
|
@ -96,4 +96,3 @@ class PyTeXConfig(Config):
|
|||
return FormattingConfig()
|
||||
else:
|
||||
return self._default_formatting_config
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class RelativePath:
|
|||
"""
|
||||
Represents a path that knows of its corresponding root directory
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
root_dir: Path,
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
|
||||
|
||||
class PyTeXFileType(Enum):
|
||||
PyTeXSourceFile = 'PyTeXSourceFile'
|
||||
TeXSourceFile = 'TeXSourceFile'
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from typing import Optional, List, Dict, Tuple, Union
|
||||
from pathlib import Path
|
||||
from .enums import PyTeXFileType
|
||||
from PyTeX.format.formatterif import FormatterIF
|
||||
from typing import Optional, List, Dict, Tuple, Union
|
||||
|
||||
from PyTeX.build.paths import RelativePath
|
||||
from ...format.enums import TeXType
|
||||
from PyTeX.format.formatterif import FormatterIF
|
||||
from .enums import PyTeXFileType
|
||||
|
||||
|
||||
class PyTeXSourceFile:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import git
|
||||
from typing import Union, Optional, List
|
||||
from pathlib import Path
|
||||
from typing import Union, Optional, List
|
||||
|
||||
import git
|
||||
|
||||
|
||||
def get_latest_commit(repo):
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
|
||||
class PyTeXException(Exception):
|
||||
pass
|
||||
|
|
|
@ -85,7 +85,6 @@ class Config:
|
|||
|
||||
|
||||
def recursive_merge_dictionaries(dict1: Dict, dict2: Dict) -> Dict:
|
||||
|
||||
aux1 = {
|
||||
k: v for k, v in dict1.items() if type(v) == dict
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import csv
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Tuple, Optional
|
||||
import csv
|
||||
from .pytex_formatter import PyTeXFormatter
|
||||
|
||||
from .constants import *
|
||||
from .pytex_formatter import PyTeXFormatter
|
||||
from ..logger import logger
|
||||
|
||||
|
||||
|
@ -58,7 +59,7 @@ class DictFormatter(PyTeXFormatter):
|
|||
dict_name=self._dict_name,
|
||||
language=language
|
||||
)
|
||||
lines += ['\n']*2
|
||||
lines += ['\n'] * 2
|
||||
for key in self.translations[language].keys():
|
||||
if self.translations[language][key].strip() != '':
|
||||
lines += r'\providetranslation{{{key}}}{{{translation}}}'.format(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from typing import List, Optional, Dict, Tuple
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Dict, Tuple
|
||||
|
||||
from .config import Config
|
||||
|
||||
|
@ -9,6 +9,7 @@ class FormatterIF:
|
|||
A formatter is bound to a specific input file with some
|
||||
building configuration.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
input_file: Optional[Path] = None,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from typing import List, Optional, Dict, Union
|
||||
|
||||
from .config import Config
|
||||
from .constants import *
|
||||
from .enums import NamingScheme
|
||||
from .enums import TeXType, TeXFlavour
|
||||
from .generic_text import GenericText
|
||||
from .git_version_info import GitVersionInfo
|
||||
from .constants import *
|
||||
from .enums import TeXType, TeXFlavour
|
||||
|
||||
|
||||
class VersionInfo:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path
|
||||
from typing import Union, List, Optional
|
||||
|
||||
from ..logger import logger
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from typing import List, Union
|
||||
from enum import Enum
|
||||
import re
|
||||
from enum import Enum
|
||||
from typing import List, Union
|
||||
|
||||
from .constants import *
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import re
|
||||
from pathlib import Path
|
||||
from typing import Optional, List
|
||||
from .formatting_config import FormattingConfig
|
||||
from typing import Optional
|
||||
|
||||
from .constants import *
|
||||
from .enums import TeXType, TeXFlavour
|
||||
from .formatterif import FormatterIF
|
||||
from .formatting_config import FormattingConfig
|
||||
from .generic_text import GenericText
|
||||
import re
|
||||
from .constants import *
|
||||
from ..logger import logger
|
||||
|
||||
|
||||
|
@ -119,8 +120,8 @@ class PyTeXFormatter(FormatterIF):
|
|||
def make_header(self, **kwargs) -> str:
|
||||
return '\n'.join(
|
||||
[
|
||||
'%'*80,
|
||||
'%' * 80,
|
||||
self.header.format(**kwargs), # TODO: add standard keywords here
|
||||
'%'*80
|
||||
'%' * 80
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from typing import List, TextIO, Optional, Tuple, Dict
|
||||
from pathlib import Path
|
||||
from .pytex_formatter import PyTeXFormatter
|
||||
from typing import List, TextIO, Optional, Tuple, Dict
|
||||
|
||||
from .macros import Macro
|
||||
from .pytex_formatter import PyTeXFormatter
|
||||
|
||||
|
||||
class LineStream:
|
||||
|
@ -38,7 +39,7 @@ class LineStream:
|
|||
self._cached_lines[pos] = line
|
||||
|
||||
def reserve_lines(self, num_lines):
|
||||
for i in range(0, num_lines - len(self._cached_lines) -1):
|
||||
for i in range(0, num_lines - len(self._cached_lines) - 1):
|
||||
self._cached_lines.append(
|
||||
self._handle.readline()
|
||||
)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import logging
|
||||
|
||||
formatter = logging.Formatter("[{name}] [{levelname}] {message}", style="{")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from typing import Tuple, Union, List, Any, Optional
|
||||
from typing import Tuple, Union, List, Any
|
||||
|
||||
from PyTeX.format.enums import NamingScheme
|
||||
from PyTeX.format.generic_text import GenericText
|
||||
from PyTeX.format.git_version_info import GitVersionInfo
|
||||
|
||||
|
||||
def generate_properties(props):
|
||||
|
@ -60,6 +60,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
print(out2)
|
||||
|
||||
|
||||
def generate_properties(attributes: List[Union[str, Tuple[str, Any]]]):
|
||||
attributes = [
|
||||
x if isinstance(x, Tuple) else (x, None) for x in attributes
|
||||
|
@ -78,4 +79,3 @@ def generate_properties(attributes: List[Union[str, Tuple[str, Any]]]):
|
|||
return cls
|
||||
|
||||
return decorator
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
from pathlib import Path, PurePath, PurePosixPath, PureWindowsPath
|
||||
|
||||
from PyTeX.build.build import PyTeXBuilder
|
||||
from PyTeX.build.enums.enums import PyTeXRootDirType
|
||||
import os
|
||||
|
||||
|
||||
class PyTeXPurePath:
|
||||
|
|
17
main.py
17
main.py
|
@ -1,13 +1,10 @@
|
|||
from pathlib import Path
|
||||
from PyTeX.build.build import PyTeXBuilder, BuildDirConfig
|
||||
|
||||
from PyTeX.build.build import PyTeXBuilder
|
||||
from PyTeX.build.build.build_dir_spec import BuildDirConfig
|
||||
from PyTeX.build.enums import *
|
||||
from PyTeX.build.paths import RelativePath
|
||||
|
||||
from PyTeX.build.build.pytex_config import PyTeXConfig
|
||||
|
||||
from PyTeX.build.paths import RelativePath
|
||||
from PyTeX.format.formatting_config import FormattingConfig
|
||||
from PyTeX.format.generic_text import GenericText
|
||||
|
||||
spec = BuildDirConfig(
|
||||
source_root=Path('src'),
|
||||
|
@ -21,7 +18,6 @@ builder = PyTeXBuilder(
|
|||
build_dir_spec=spec
|
||||
)
|
||||
|
||||
|
||||
p: RelativePath = RelativePath(Path('src'), 'src/hello/bla')
|
||||
|
||||
rel = p.relative_path
|
||||
|
@ -34,7 +30,6 @@ p2 = RelativePath(Path('doc'), 'build/doc/mkessler/hello/bla')
|
|||
|
||||
p3 = p / p2
|
||||
|
||||
|
||||
p4 = p.with_name('myname')
|
||||
|
||||
d1 = {
|
||||
|
@ -49,18 +44,12 @@ d2 = {
|
|||
|
||||
d3 = d1 | d2
|
||||
|
||||
|
||||
config: FormattingConfig = FormattingConfig()
|
||||
|
||||
|
||||
dump = config.to_json()
|
||||
|
||||
|
||||
conf_path = Path('/home/maximilian/git/LatexPackages/.pytexrc')
|
||||
|
||||
pytex_config = PyTeXConfig.from_yaml(conf_path)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue