Skip to content

Commit ed63123

Browse files
Implemented changes suggested in class
renamed: class Installation -> Installer added: object variable _language_link renamed: main() -> install_apertium_windows()
1 parent 00cc400 commit ed63123

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

installer.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
from shutil import rmtree
88

99

10-
class Installation:
10+
class Installer:
1111

1212
def __init__(self, languages: tuple):
1313
self._install_path = os.getenv('LOCALAPPDATA')
1414
self._apertium_path = path.join(self._install_path, 'apertium-all-dev')
1515
self._temp_path = os.getenv('TEMP')
1616
self._download_path = path.join(self._temp_path, 'apertium_temp')
17+
self._language_link = 'http://apertium.projectjj.com/win32/nightly/data.php?zip={}'
1718

1819
# Remove abandoned files from previous incomplete install
1920
if path.isdir(self._download_path):
@@ -57,7 +58,7 @@ def download_language_data(self):
5758
extract_path = self._download_path
5859
language_zip = dict()
5960
for curr_lang in self._languages:
60-
language_link = f'http://apertium.projectjj.com/win32/nightly/data.php?zip={curr_lang}'
61+
language_link = self._language_link.format(curr_lang)
6162
language_zip[curr_lang] = language_link
6263

6364
self._download_zip(language_zip, download_dir, extract_path)
@@ -111,15 +112,15 @@ def mode_editor(self):
111112
print(f"Closing {file}")
112113

113114

114-
def main():
115+
def install_apertium_windows():
115116
# Download ApertiumWin64 and Move to %localappdata%
116117

117-
p = Installation(('apertium-eng', 'apertium-en-es'))
118-
p.download_apertium_windows()
119-
p.download_language_data()
120-
p.mode_editor()
118+
if platform.system() == 'Windows':
119+
p = Installer(('apertium-eng', 'apertium-en-es'))
120+
p.download_apertium_windows()
121+
p.download_language_data()
122+
p.mode_editor()
121123

122124

123125
if __name__ == '__main__':
124-
if platform.system() == 'Windows':
125-
main()
126+
install_apertium_windows()

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from setuptools import setup
22
from setuptools.command.install import install
33
from atexit import register
4-
from platform import system
5-
import installation
4+
import installer
65

76

87
class PostInstallCommand(install):
@@ -12,8 +11,7 @@ def __init__(self, *args, **kwargs):
1211

1312
@staticmethod
1413
def _post_install():
15-
if system() == 'Windows':
16-
installation.main()
14+
installer.install_apertium_windows()
1715

1816

1917
setup(

0 commit comments

Comments
 (0)