From 87666fbec6c61341f56bf65eb0b5528b4a5555a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 17 Feb 2022 20:37:38 +0100 Subject: [PATCH] move close output stream method to tex formatter --- PyTeX/format/simple_tex_formatter.py | 3 --- PyTeX/format/tex_formatter.py | 16 +++++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/PyTeX/format/simple_tex_formatter.py b/PyTeX/format/simple_tex_formatter.py index d42b650..c9a1d95 100644 --- a/PyTeX/format/simple_tex_formatter.py +++ b/PyTeX/format/simple_tex_formatter.py @@ -14,9 +14,6 @@ class SimpleTeXFormatter(TexFormatter): } return self.name + switcher[self.config.tex_type] - def close_output_stream(self): - self._output_file.close() - @property def future_config(self) -> List[Tuple[str, FormattingConfig]]: return [] # TODO diff --git a/PyTeX/format/tex_formatter.py b/PyTeX/format/tex_formatter.py index f2cb82b..e526fef 100644 --- a/PyTeX/format/tex_formatter.py +++ b/PyTeX/format/tex_formatter.py @@ -75,12 +75,8 @@ class TexFormatter(PyTeXFormatter, ABC): else: self._output_file = out_file.open('w') - @abstractmethod def close_output_stream(self) -> None: - """ - - :return: - """ + self._output_file.close() @property @abstractmethod @@ -123,8 +119,14 @@ class TexFormatter(PyTeXFormatter, ABC): """ return line.rstrip() - def _shipout_line(self, line): - self.write_line(line + '\n') + def _shipout_line(self, line) -> None: + """ + The line might get dropped according to current mode + + :param line: Line to shipout + :return: None + """ + self.write_line(line.rstrip('\n') + '\n') def write_line(self, line: str): if self._output_file is None: