dump yaml config (still wrong)
This commit is contained in:
parent
97bc1fd50f
commit
fbb7771dee
4 changed files with 26 additions and 2 deletions
|
@ -50,6 +50,7 @@ class PyTeXBuilder:
|
||||||
self._files_to_build: Set[PyTeXSourceFile] = set()
|
self._files_to_build: Set[PyTeXSourceFile] = set()
|
||||||
self._tmp_dir: Path = self._root_dir / '.pytex'
|
self._tmp_dir: Path = self._root_dir / '.pytex'
|
||||||
self._git_version_info: GitVersionInfo = self._foo()
|
self._git_version_info: GitVersionInfo = self._foo()
|
||||||
|
self._new_config: PyTeXConfig = PyTeXConfig()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _foo(self):
|
def _foo(self):
|
||||||
|
@ -271,11 +272,16 @@ class PyTeXBuilder:
|
||||||
# TODO actually, this is not totally correct
|
# TODO actually, this is not totally correct
|
||||||
|
|
||||||
def _build_files(self):
|
def _build_files(self):
|
||||||
|
self._new_config.sub_configs = {}
|
||||||
for source_file in self._files_to_build:
|
for source_file in self._files_to_build:
|
||||||
out_dir = self._tmp_dir / source_file.file_hash
|
out_dir = self._tmp_dir / source_file.file_hash
|
||||||
out_dir.mkdir(exist_ok=False, parents=True)
|
out_dir.mkdir(exist_ok=False, parents=True)
|
||||||
new_config: List[Tuple[RelativePath, FormattingConfig]] = \
|
new_config: List[Tuple[RelativePath, FormattingConfig]] = \
|
||||||
source_file.format(self._tmp_dir / source_file.file_hash)
|
source_file.format(self._tmp_dir / source_file.file_hash)
|
||||||
|
for rel_path, config in new_config:
|
||||||
|
self._new_config.sub_configs[
|
||||||
|
rel_path.name
|
||||||
|
] = config
|
||||||
for filename in source_file.output_files:
|
for filename in source_file.output_files:
|
||||||
logger.verbose(f"[Built] {filename}")
|
logger.verbose(f"[Built] {filename}")
|
||||||
for output_file in source_file.output_files:
|
for output_file in source_file.output_files:
|
||||||
|
@ -293,6 +299,12 @@ class PyTeXBuilder:
|
||||||
file_version_info.git_version_info = source_file.formatter.git_version_info # TODO:
|
file_version_info.git_version_info = source_file.formatter.git_version_info # TODO:
|
||||||
# only pytex formatters
|
# only pytex formatters
|
||||||
|
|
||||||
|
def _dump_new_config(self):
|
||||||
|
self.target_root.mkdir(exist_ok=True, parents=True)
|
||||||
|
self._new_config.dump_as_yaml(
|
||||||
|
self.target_root / '.pytexrc'
|
||||||
|
)
|
||||||
|
|
||||||
def _move_files(self):
|
def _move_files(self):
|
||||||
for source_file in self._files_to_build:
|
for source_file in self._files_to_build:
|
||||||
tmp_dir = self._tmp_dir / source_file.file_hash
|
tmp_dir = self._tmp_dir / source_file.file_hash
|
||||||
|
@ -329,6 +341,7 @@ class PyTeXBuilder:
|
||||||
e.add_explanation('while building output files')
|
e.add_explanation('while building output files')
|
||||||
raise e
|
raise e
|
||||||
logger.info(f"Built files")
|
logger.info(f"Built files")
|
||||||
|
self._dump_new_config()
|
||||||
self._move_files()
|
self._move_files()
|
||||||
self._write_version_info()
|
self._write_version_info()
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Optional, Dict
|
from typing import Optional, Dict, List
|
||||||
|
|
||||||
from PyTeX.build.build import BuildDirConfig
|
from PyTeX.build.build import BuildDirConfig
|
||||||
from PyTeX.format.formatting_config import FormattingConfig
|
from PyTeX.format.formatting_config import FormattingConfig
|
||||||
|
@ -110,3 +110,8 @@ class PyTeXConfig(Config):
|
||||||
else:
|
else:
|
||||||
return FormattingConfig()
|
return FormattingConfig()
|
||||||
|
|
||||||
|
@sub_configs.setter
|
||||||
|
def sub_configs(self, configs: List[FormattingConfig]):
|
||||||
|
self._configs = configs
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ class DTXFormatter(TexFormatter):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def future_config(self) -> List[Tuple[str, FormattingConfig]]:
|
def future_config(self) -> List[Tuple[str, FormattingConfig]]:
|
||||||
return [] # TODO
|
config = FormattingConfig()
|
||||||
|
config.tex_out_type = self.config.tex_out_type
|
||||||
|
return [(self.name + '.dtx', config)]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def output_files(self) -> List[str]:
|
def output_files(self) -> List[str]:
|
||||||
|
|
|
@ -389,6 +389,10 @@ class FormattingConfig(Config):
|
||||||
else:
|
else:
|
||||||
return self._tex_out_type
|
return self._tex_out_type
|
||||||
|
|
||||||
|
@tex_out_type.setter
|
||||||
|
def tex_out_type(self, value):
|
||||||
|
self._tex_out_type = value
|
||||||
|
|
||||||
|
|
||||||
class DocFormattingConfig:
|
class DocFormattingConfig:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Loading…
Reference in a new issue