refactor builder into own file

This commit is contained in:
Maximilian Keßler 2022-02-05 21:44:52 +01:00
parent 1cdb9964e7
commit dd85f7425d
6 changed files with 60 additions and 19 deletions

View file

@ -0,0 +1,2 @@
from .build_dir_spec import BuildDirSpecification
from .builder import PyTeXBuilder

View file

@ -1,6 +1,5 @@
from pathlib import Path, PurePath
from typing import Optional
from PyTeX.format.formatting_config import FormattingConfig
from ..enums import PyTeXRootDirType
@ -52,19 +51,3 @@ class BuildDirSpecification:
raise NotImplementedError
class PyTeXBuilder:
def __init__(
self,
build_dir_spec: BuildDirSpecification
):
self._build_spec: BuildDirSpecification = None
self._default_formatting_config: Optional[FormattingConfig] = None
self._recursive: bool = True
self._overwrite_existing_files: bool = False
self._clean_old_files: True
self._allow_dirty: bool = False

View file

@ -0,0 +1,20 @@
from typing import Optional
from PyTeX.build.build import BuildDirSpecification
from PyTeX.format.formatting_config import FormattingConfig
class PyTeXBuilder:
def __init__(
self,
build_dir_spec: BuildDirSpecification
):
self._build_spec: BuildDirSpecification = None
self._default_formatting_config: Optional[FormattingConfig] = None
self._recursive: bool = True
self._overwrite_existing_files: bool = False
self._clean_old_files: True
self._allow_dirty: bool = False

View file

@ -1 +0,0 @@
from .global_config import PyTeXBuilder, BuildDirSpecification

View file

@ -1,5 +1,5 @@
from pathlib import Path, PurePath, PurePosixPath, PureWindowsPath
from PyTeX.build.config.global_config import PyTeXBuilder
from PyTeX.build.build import PyTeXBuilder
from PyTeX.build.enums.enums import PyTeXRootDirType
import os

37
main.py Normal file
View file

@ -0,0 +1,37 @@
from pathlib import Path
from PyTeX.build.build import PyTeXBuilder
from PyTeX.build.build.build_dir_spec import BuildDirSpecification
from PyTeX.build.enums import *
from PyTeX.build.paths import RelativePath
spec = BuildDirSpecification(
source_root=Path('src'),
tex_root=Path('build/source'),
build_root=Path('build'),
doc_root=Path('build/doc'),
wrapper_dir=Path('mkessler')
)
builder = PyTeXBuilder(
build_dir_spec=spec
)
p: RelativePath = RelativePath(Path('src'), 'src/hello/bla')
rel = p.relative_path
q = p / 'test'
re2 = q.relative_path
p2 = RelativePath(Path('doc'), 'build/doc/mkessler/hello/bla')
p3 = p / p2
p4 = p.with_name('myname')
print(p)