Skip to content

Commit

Permalink
Implemented changes suggested in class
Browse files Browse the repository at this point in the history
renamed: class Installation -> Installer
added: object variable _language_link
renamed: main() -> install_apertium_windows()
  • Loading branch information
singh-lokendra committed Apr 6, 2019
1 parent 00cc400 commit ed63123
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 10 additions & 9 deletions installer.py
Expand Up @@ -7,13 +7,14 @@
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):
Expand Down Expand Up @@ -57,7 +58,7 @@ def download_language_data(self):
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)
Expand Down Expand Up @@ -111,15 +112,15 @@ def mode_editor(self):
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()
6 changes: 2 additions & 4 deletions 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):
Expand All @@ -12,8 +11,7 @@ def __init__(self, *args, **kwargs):

@staticmethod
def _post_install():
if system() == 'Windows':
installation.main()
installer.install_apertium_windows()


setup(
Expand Down

0 comments on commit ed63123

Please sign in to comment.