dump yaml config (still wrong)

This commit is contained in:
Maximilian Keßler 2022-02-18 21:40:44 +01:00
parent 97bc1fd50f
commit fbb7771dee
4 changed files with 26 additions and 2 deletions

View file

@ -50,6 +50,7 @@ class PyTeXBuilder:
self._files_to_build: Set[PyTeXSourceFile] = set()
self._tmp_dir: Path = self._root_dir / '.pytex'
self._git_version_info: GitVersionInfo = self._foo()
self._new_config: PyTeXConfig = PyTeXConfig()
pass
def _foo(self):
@ -271,11 +272,16 @@ class PyTeXBuilder:
# TODO actually, this is not totally correct
def _build_files(self):
self._new_config.sub_configs = {}
for source_file in self._files_to_build:
out_dir = self._tmp_dir / source_file.file_hash
out_dir.mkdir(exist_ok=False, parents=True)
new_config: List[Tuple[RelativePath, FormattingConfig]] = \
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:
logger.verbose(f"[Built] {filename}")
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:
# 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):
for source_file in self._files_to_build:
tmp_dir = self._tmp_dir / source_file.file_hash
@ -329,6 +341,7 @@ class PyTeXBuilder:
e.add_explanation('while building output files')
raise e
logger.info(f"Built files")
self._dump_new_config()
self._move_files()
self._write_version_info()
return True

View file

@ -1,4 +1,4 @@
from typing import Optional, Dict
from typing import Optional, Dict, List
from PyTeX.build.build import BuildDirConfig
from PyTeX.format.formatting_config import FormattingConfig
@ -110,3 +110,8 @@ class PyTeXConfig(Config):
else:
return FormattingConfig()
@sub_configs.setter
def sub_configs(self, configs: List[FormattingConfig]):
self._configs = configs

View file

@ -14,7 +14,9 @@ class DTXFormatter(TexFormatter):
@property
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
def output_files(self) -> List[str]:

View file

@ -389,6 +389,10 @@ class FormattingConfig(Config):
else:
return self._tex_out_type
@tex_out_type.setter
def tex_out_type(self, value):
self._tex_out_type = value
class DocFormattingConfig:
def __init__(self):