commit ed6312358a8384570f263f5b6e88eef5df3cc9fa Author: Vaydheesh Date: Sat Apr 6 19:28:52 2019 +0530 Implemented changes suggested in class renamed: class Installation -> Installer added: object variable _language_link renamed: main() -> install_apertium_windows() diff --git a/installer.py b/installer.py index 3a938f5..0e56723 100644 --- a/installer.py +++ b/installer.py @@ -7,13 +7,14 @@ from distutils.dir_util import copy_tree from shutil import rmtree -class Installation: +class Installer: def __init__(self, languages: tuple): self._install_path = os.getenv('LOCALAPPDATA') self._apertium_path = path.join(self._install_path, 'apertium-all-dev') self._temp_path = os.getenv('TEMP') self._download_path = path.join(self._temp_path, 'apertium_temp') + self._language_link = 'http://apertium.projectjj.com/win32/nightly/data.php?zip={}' # Remove abandoned files from previous incomplete install if path.isdir(self._download_path): @@ -57,7 +58,7 @@ class Installation: extract_path = self._download_path language_zip = dict() for curr_lang in self._languages: - language_link = f'http://apertium.projectjj.com/win32/nightly/data.php?zip={curr_lang}' + language_link = self._language_link.format(curr_lang) language_zip[curr_lang] = language_link self._download_zip(language_zip, download_dir, extract_path) @@ -111,15 +112,15 @@ class Installation: print(f"Closing {file}") -def main(): +def install_apertium_windows(): # Download ApertiumWin64 and Move to %localappdata% - p = Installation(('apertium-eng', 'apertium-en-es')) - p.download_apertium_windows() - p.download_language_data() - p.mode_editor() + if platform.system() == 'Windows': + p = Installer(('apertium-eng', 'apertium-en-es')) + p.download_apertium_windows() + p.download_language_data() + p.mode_editor() if __name__ == '__main__': - if platform.system() == 'Windows': - main() + install_apertium_windows() diff --git a/setup.py b/setup.py index 47f5ca9..a8dd9d5 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,7 @@ from setuptools import setup from setuptools.command.install import install from atexit import register -from platform import system -import installation +import installer class PostInstallCommand(install): @@ -12,8 +11,7 @@ class PostInstallCommand(install): @staticmethod def _post_install(): - if system() == 'Windows': - installation.main() + installer.install_apertium_windows() setup(