refactor builder into own file
This commit is contained in:
parent
1cdb9964e7
commit
dd85f7425d
6 changed files with 60 additions and 19 deletions
2
PyTeX/build/build/__init__.py
Normal file
2
PyTeX/build/build/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
from .build_dir_spec import BuildDirSpecification
|
||||||
|
from .builder import PyTeXBuilder
|
|
@ -1,6 +1,5 @@
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from PyTeX.format.formatting_config import FormattingConfig
|
|
||||||
|
|
||||||
from ..enums import PyTeXRootDirType
|
from ..enums import PyTeXRootDirType
|
||||||
|
|
||||||
|
@ -52,19 +51,3 @@ class BuildDirSpecification:
|
||||||
raise NotImplementedError
|
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
|
|
||||||
|
|
||||||
|
|
20
PyTeX/build/build/builder.py
Normal file
20
PyTeX/build/build/builder.py
Normal 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
|
|
@ -1 +0,0 @@
|
||||||
from .global_config import PyTeXBuilder, BuildDirSpecification
|
|
|
@ -1,5 +1,5 @@
|
||||||
from pathlib import Path, PurePath, PurePosixPath, PureWindowsPath
|
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
|
from PyTeX.build.enums.enums import PyTeXRootDirType
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
37
main.py
Normal file
37
main.py
Normal 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)
|
Loading…
Reference in a new issue