rework format method to support multiple output files
This commit is contained in:
parent
6798962880
commit
3e6f2f99c3
2 changed files with 14 additions and 16 deletions
|
@ -14,13 +14,6 @@ class SimpleTeXFormatter(TexFormatter):
|
|||
}
|
||||
return self.name + switcher[self.config.tex_type]
|
||||
|
||||
def open_output_stream(self, build_dir: Path):
|
||||
out_file = build_dir / self.output_file
|
||||
if out_file.exists():
|
||||
raise NotImplementedError
|
||||
else:
|
||||
self._output_file = out_file.open('w')
|
||||
|
||||
def close_output_stream(self):
|
||||
self._output_file.close()
|
||||
|
||||
|
|
|
@ -62,12 +62,16 @@ class TexFormatter(PyTeXFormatter, ABC):
|
|||
self._macros: List[Macro] = []
|
||||
self._line_stream: Optional[LineStream] = None
|
||||
|
||||
@abstractmethod
|
||||
def open_output_stream(self, build_dir: Path) -> None:
|
||||
def open_output_stream(self, build_dir: Path, filename: str) -> None:
|
||||
"""
|
||||
|
||||
:param build_dir: Where to open output stream
|
||||
:param filename: Name of file
|
||||
"""
|
||||
out_file = build_dir / filename
|
||||
if out_file.exists():
|
||||
raise NotImplementedError
|
||||
else:
|
||||
self._output_file = out_file.open('w')
|
||||
|
||||
@abstractmethod
|
||||
def close_output_stream(self) -> None:
|
||||
|
@ -151,7 +155,8 @@ class TexFormatter(PyTeXFormatter, ABC):
|
|||
))
|
||||
|
||||
def format(self, build_dir: Path, overwrite: bool = False) -> List[Tuple[str, FormattingConfig]]:
|
||||
self.open_output_stream(build_dir)
|
||||
for filename in self.output_files:
|
||||
self.open_output_stream(build_dir, filename)
|
||||
self.format_pre_header()
|
||||
self.format_header()
|
||||
self.format_post_header()
|
||||
|
|
Loading…
Reference in a new issue