@@ -34,17 +34,18 @@ def fetch():
3434 """
3535 Fetch translations from Transifex, remove source lines.
3636 """
37- if call ("tx --version" , shell = True ) != 0 :
37+ if ( code := call ("tx --version" , shell = True ) ) != 0 :
3838 sys .stderr .write ("The Transifex client app is required.\n " )
39- exit (1 )
39+ exit (code )
4040 lang = LANGUAGE
41- pull_returncode = call (
42- f'tx pull -l { lang } --minimum-perc=1 --force --skip' , shell = True
43- )
44- if pull_returncode != 0 :
45- exit (pull_returncode )
41+ _call (f'tx pull -l { lang } --minimum-perc=1 --force --skip' )
4642 for file in Path ().rglob ('*.po' ):
47- call (f'msgcat --no-location -o { file } { file } ' , shell = True )
43+ _call (f'msgcat --no-location -o { file } { file } ' )
44+
45+
46+ def _call (command : str ):
47+ if (return_code := call (command , shell = True )) != 0 :
48+ exit (return_code )
4849
4950
5051PROJECT_SLUG = 'python-311'
@@ -70,33 +71,24 @@ def recreate_tx_config():
7071
7172
7273def _clone_cpython_repo (version : str ):
73- if (status := call (
74- f'git clone -b { version } --single-branch https://github.com/python/cpython.git --depth 1' , shell = True
75- )) != 0 :
76- exit (status )
74+ _call (f'git clone -b { version } --single-branch https://github.com/python/cpython.git --depth 1' )
7775
7876
7977def _build_gettext ():
80- if (status := call (
81- "make -C cpython/Doc/ "
82- "ALLSPHINXOPTS='-E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot' build" ,
83- shell = True ,
84- )) != 0 :
85- exit (status )
78+ _call (
79+ "make -C cpython/Doc/ ALLSPHINXOPTS='-E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot' build"
80+ )
8681
8782
8883def _create_txconfig ():
89- if (status := call ('sphinx-intl create-txconfig' , shell = True )) != 0 :
90- exit (status )
84+ _call ('sphinx-intl create-txconfig' )
9185
9286
9387def _update_txconfig_resources ():
94- if ( status := call (
88+ _call (
9589 f'sphinx-intl update-txconfig-resources --transifex-organization-name python-doc '
96- f'--transifex-project-name={ PROJECT_SLUG } --locale-dir . --pot-dir pot' ,
97- shell = True ,
98- )) != 0 :
99- exit (status )
90+ f'--transifex-project-name={ PROJECT_SLUG } --locale-dir . --pot-dir pot'
91+ )
10092
10193
10294@dataclass
0 commit comments