commit 592eff73e8b11a0f52966f03d73bab856682412e Author: vaydheesh Date: Wed Jun 12 20:45:19 2019 +0000 Implemented changes suggested .gitignore: Fixed IDE specific ignore apertium/analysis/__init__.py: Fixed multiple command insertion lttoolbox.py: Modified TypeAnnotation diff --git a/.gitignore b/.gitignore index 56c23b7..f6f3a83 100644 --- a/.gitignore +++ b/.gitignore @@ -101,6 +101,3 @@ ENV/ # mypy .mypy_cache/ - -# PyCharm -.idea \ No newline at end of file diff --git a/apertium/analysis/__init__.py b/apertium/analysis/__init__.py index edc3840..6fd421e 100644 --- a/apertium/analysis/__init__.py +++ b/apertium/analysis/__init__.py @@ -35,6 +35,7 @@ class Analyzer: mode_path, mode = apertium.analyzers[self.lang] abs_mode_path = os.path.join(mode_path, 'modes', '{}.mode'.format(mode)) self.analyzer_cmds[self.lang] = parse_mode_file(abs_mode_path) + return self.analyzer_cmds[self.lang] @staticmethod @@ -63,7 +64,9 @@ class Analyzer: List[LexicalUnit] """ self._get_commands() - self.analyzer_cmds[self.lang].insert(0, ['apertium-des{}'.format(formatting), '-n']) + deformatter = ['apertium-des{}'.format(formatting), '-n'] + if deformatter not in self.analyzer_cmds[self.lang]: + self.analyzer_cmds[self.lang].insert(0, deformatter) result = execute(in_text, self.analyzer_cmds[self.lang]) return self._postproc_text(result) diff --git a/apertium/lttoolbox.py b/apertium/lttoolbox.py index 4faaaf2..fa01f58 100644 --- a/apertium/lttoolbox.py +++ b/apertium/lttoolbox.py @@ -1,6 +1,7 @@ import platform import tempfile from typing import ByteString # noqa: F401 + if platform.system() == 'Linux': from apertium.swig.linux import lttoolbox elif platform.system() == 'Windows': @@ -16,7 +17,7 @@ class LtProc: output_text (str) """ - def __init__(self, input_text, arg_index, path): # type: (LtProc, str, int, str) -> None + def __init__(self, input_text: str, arg_index: str, path: str) -> None: """ Args: input_text (str) @@ -28,7 +29,7 @@ class LtProc: self.input_text = input_text self.output_text = '' - def analyze(self): # type: (LtProc) -> None + def analyze(self) -> None: """ Reads formatted text from apertium-des and returns its analysed text @@ -46,7 +47,7 @@ class LtProc: fst.analyze(self.path, input_file.name, output_file.name) self.output_text = output_file.read() - def execute(self): # type: (LtProc) -> ByteString + def execute(self) -> ByteString: """ Executes the required method, depending upon the argument for lt-proc