@@ -35,8 +35,8 @@ def fetch():
3535 """
3636 Fetch translations from Transifex, remove source lines.
3737 """
38- if (code := call (" tx --version" , shell = True )) != 0 :
39- sys .stderr .write (" The Transifex client app is required.\n " )
38+ if (code := call (' tx --version' , shell = True )) != 0 :
39+ sys .stderr .write (' The Transifex client app is required.\n ' )
4040 exit (code )
4141 lang = LANGUAGE
4242 _call (f'tx pull -l { lang } --minimum-perc=1 --force --skip' )
@@ -71,12 +71,14 @@ def recreate_tx_config():
7171 file .write (contents )
7272 warn_about_files_to_delete ()
7373
74+
7475def warn_about_files_to_delete ():
7576 files = list (_get_files_to_delete ())
7677 if not files :
7778 return
7879 warn (f'Found { len (files )} file(s) to delete: { ", " .join (files )} .' )
7980
81+
8082def _get_files_to_delete ():
8183 with open ('.tx/config' ) as config_file :
8284 config = config_file .read ()
@@ -86,11 +88,13 @@ def _get_files_to_delete():
8688
8789
8890def _clone_cpython_repo (version : str ):
89- _call (f'git clone -b { version } --single-branch https://github.com/python/cpython.git --depth 1' )
91+ _call (
92+ f'git clone -b { version } --single-branch https://github.com/python/cpython.git --depth 1'
93+ )
9094
9195
9296def _build_gettext ():
93- _call (" make -C cpython/Doc/ gettext" )
97+ _call (' make -C cpython/Doc/ gettext' )
9498
9599
96100def _create_txconfig ():
@@ -115,7 +119,9 @@ class ResourceLanguageStatistics:
115119 @classmethod
116120 def from_api_entry (cls , data : transifex_api .ResourceLanguageStats ) -> Self :
117121 return cls (
118- name = data .id .removeprefix (f'o:python-doc:p:{ PROJECT_SLUG } :r:' ).removesuffix (f':l:{ LANGUAGE } ' ),
122+ name = data .id .removeprefix (f'o:python-doc:p:{ PROJECT_SLUG } :r:' ).removesuffix (
123+ f':l:{ LANGUAGE } '
124+ ),
119125 total_words = data .attributes ['total_words' ],
120126 translated_words = data .attributes ['translated_words' ],
121127 total_strings = data .attributes ['total_strings' ],
@@ -161,21 +167,23 @@ def get_number_of_translators():
161167def _fetch_translators () -> Generator [str , None , None ]:
162168 for file in Path ().rglob ('*.po' ):
163169 header = pofile (file ).header .splitlines ()
164- for translator_record in header [header .index ('Translators:' ) + 1 :]:
170+ for translator_record in header [header .index ('Translators:' ) + 1 :]:
165171 translator , _year = translator_record .split (', ' )
166172 yield translator
167173
168174
169175def _remove_bot (translators : set [str ]) -> None :
170- translators .remove (" Transifex Bot <>" )
176+ translators .remove (' Transifex Bot <>' )
171177
172178
173179def _eliminate_aliases (translators : set [str ]) -> set [str ]:
174180 unique = set ()
175181 for name in translators :
176182 for match in unique :
177- if (ratio := SequenceMatcher (lambda x : x in '<>@' , name , match ).ratio ()) > 0.64 :
178- info (f"{ name } and { match } are similar ({ ratio :.3f} ). Deduplicating." )
183+ if (
184+ ratio := SequenceMatcher (lambda x : x in '<>@' , name , match ).ratio ()
185+ ) > 0.64 :
186+ info (f'{ name } and { match } are similar ({ ratio :.3f} ). Deduplicating.' )
179187 break
180188 else :
181189 unique .add (name )
@@ -184,10 +192,12 @@ def _eliminate_aliases(translators: set[str]) -> set[str]:
184192
185193def language_switcher (entry : ResourceLanguageStatistics ) -> bool :
186194 language_switcher_resources_prefixes = ('bugs' , 'tutorial' , 'library--functions' )
187- return any (entry .name .startswith (prefix ) for prefix in language_switcher_resources_prefixes )
195+ return any (
196+ entry .name .startswith (prefix ) for prefix in language_switcher_resources_prefixes
197+ )
188198
189199
190- if __name__ == " __main__" :
200+ if __name__ == ' __main__' :
191201 RUNNABLE_SCRIPTS = ('fetch' , 'recreate_tx_config' , 'warn_about_files_to_delete' )
192202
193203 parser = ArgumentParser ()
0 commit comments