|
7 | 7 | from shutil import rmtree
|
8 | 8 |
|
9 | 9 |
|
10 |
| -class Installation: |
| 10 | +class Installer: |
11 | 11 |
|
12 | 12 | def __init__(self, languages: tuple):
|
13 | 13 | self._install_path = os.getenv('LOCALAPPDATA')
|
14 | 14 | self._apertium_path = path.join(self._install_path, 'apertium-all-dev')
|
15 | 15 | self._temp_path = os.getenv('TEMP')
|
16 | 16 | self._download_path = path.join(self._temp_path, 'apertium_temp')
|
| 17 | + self._language_link = 'http://apertium.projectjj.com/win32/nightly/data.php?zip={}' |
17 | 18 |
|
18 | 19 | # Remove abandoned files from previous incomplete install
|
19 | 20 | if path.isdir(self._download_path):
|
@@ -57,7 +58,7 @@ def download_language_data(self):
|
57 | 58 | extract_path = self._download_path
|
58 | 59 | language_zip = dict()
|
59 | 60 | 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) |
61 | 62 | language_zip[curr_lang] = language_link
|
62 | 63 |
|
63 | 64 | self._download_zip(language_zip, download_dir, extract_path)
|
@@ -111,15 +112,15 @@ def mode_editor(self):
|
111 | 112 | print(f"Closing {file}")
|
112 | 113 |
|
113 | 114 |
|
114 |
| -def main(): |
| 115 | +def install_apertium_windows(): |
115 | 116 | # Download ApertiumWin64 and Move to %localappdata%
|
116 | 117 |
|
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() |
121 | 123 |
|
122 | 124 |
|
123 | 125 | if __name__ == '__main__':
|
124 |
| - if platform.system() == 'Windows': |
125 |
| - main() |
| 126 | + install_apertium_windows() |
0 commit comments