fix some bugs in formatters
This commit is contained in:
parent
25935f4350
commit
2222e20e47
2 changed files with 4 additions and 3 deletions
|
@ -53,12 +53,12 @@ class DictFormatter(PyTeXFormatter):
|
||||||
if not len(line) == len(self._languages) + 1:
|
if not len(line) == len(self._languages) + 1:
|
||||||
raise NotImplementedError # Invalid file format
|
raise NotImplementedError # Invalid file format
|
||||||
for n in range(1, len(line)):
|
for n in range(1, len(line)):
|
||||||
translations[self._languages[n]][line[0]] = line[n]
|
translations[self._languages[n-1]][line[0]] = line[n]
|
||||||
return translations
|
return translations
|
||||||
|
|
||||||
def format(self, build_dir: Path, overwrite: bool = False) -> List[Tuple[str, FormattingConfig]]:
|
def format(self, build_dir: Path, overwrite: bool = False) -> List[Tuple[str, FormattingConfig]]:
|
||||||
build_dir.mkdir(parents=True, exist_ok=True)
|
build_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.make_header()
|
self.make_header() # TODO: add kwargs
|
||||||
for language in self._languages:
|
for language in self._languages:
|
||||||
lines: List[str] = [self.make_header(), '']
|
lines: List[str] = [self.make_header(), '']
|
||||||
lines += r'\ProvidesDictionary{{{dict_name}}}{{{language}}}'.format(
|
lines += r'\ProvidesDictionary{{{dict_name}}}{{{language}}}'.format(
|
||||||
|
@ -87,7 +87,7 @@ class DictFormatter(PyTeXFormatter):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
else:
|
else:
|
||||||
output_file.write_text(
|
output_file.write_text(
|
||||||
'\n'.join(lines)
|
''.join(lines)
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
f'Successfully wrote dictionary file {output_file.name}.'
|
f'Successfully wrote dictionary file {output_file.name}.'
|
||||||
|
|
|
@ -15,6 +15,7 @@ class SimpleTeXFormatter(TexFormatter):
|
||||||
def close_output_stream(self):
|
def close_output_stream(self):
|
||||||
self._output_file.close()
|
self._output_file.close()
|
||||||
|
|
||||||
|
@property
|
||||||
def future_config(self) -> List[Tuple[str, FormattingConfig]]:
|
def future_config(self) -> List[Tuple[str, FormattingConfig]]:
|
||||||
return [] # TODO
|
return [] # TODO
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue