|
17 | 17 | import os
|
18 | 18 | from contextlib import chdir
|
19 | 19 | from dataclasses import dataclass
|
20 |
| -from difflib import SequenceMatcher |
21 |
| -from logging import info |
22 | 20 | from pathlib import Path
|
23 | 21 | from subprocess import call, run, CalledProcessError
|
24 | 22 | import sys
|
25 | 23 | from tempfile import TemporaryDirectory
|
26 |
| -from typing import Self, Generator, Iterable |
| 24 | +from typing import Self, Iterable |
27 | 25 | from warnings import warn
|
28 | 26 |
|
29 | 27 | from polib import pofile, POFile
|
@@ -163,39 +161,6 @@ def progress_from_resources(
|
163 | 161 | )
|
164 | 162 |
|
165 | 163 |
|
166 |
| -def get_number_of_translators(): |
167 |
| - translators = set(_fetch_translators()) |
168 |
| - _remove_bot(translators) |
169 |
| - translators = _eliminate_aliases(translators) |
170 |
| - return len(translators) |
171 |
| - |
172 |
| - |
173 |
| -def _fetch_translators() -> Generator[str, None, None]: |
174 |
| - for file in Path().rglob('*.po'): |
175 |
| - header = pofile(file).header.splitlines() |
176 |
| - for translator_record in header[header.index('Translators:') + 1 :]: |
177 |
| - translator, _year = translator_record.split(', ') |
178 |
| - yield translator |
179 |
| - |
180 |
| - |
181 |
| -def _remove_bot(translators: set[str]) -> None: |
182 |
| - translators.remove('Transifex Bot <>') |
183 |
| - |
184 |
| - |
185 |
| -def _eliminate_aliases(translators: set[str]) -> set[str]: |
186 |
| - unique = set() |
187 |
| - for name in translators: |
188 |
| - for match in unique: |
189 |
| - if ( |
190 |
| - ratio := SequenceMatcher(lambda x: x in '<>@', name, match).ratio() |
191 |
| - ) > 0.64: |
192 |
| - info(f'{name} and {match} are similar ({ratio:.3f}). Deduplicating.') |
193 |
| - break |
194 |
| - else: |
195 |
| - unique.add(name) |
196 |
| - return unique |
197 |
| - |
198 |
| - |
199 | 164 | def language_switcher(entry: ResourceLanguageStatistics) -> bool:
|
200 | 165 | language_switcher_resources_prefixes = ('bugs', 'tutorial', 'library--functions')
|
201 | 166 | return any(
|
|
0 commit comments