Skip to content

Commit 15ce4c1

Browse files
committed
Refactor patching process in transifex-util.py to use Python script for better readability and error handling
1 parent c5d2087 commit 15ce4c1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/transifex-pull.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,17 @@ jobs:
4444
- run: chmod +x transifex-util.py
4545
- name: Patch helper for cross-version Doc Makefile compatibility
4646
run: |
47-
sed -i 's|_call("make -C cpython/Doc/ gettext")|_call("make -C cpython/Doc/ JOBS=1 gettext || make -C cpython/Doc/ JOBS=1 build BUILDER=gettext")|' transifex-util.py
47+
python - <<'PY'
48+
from pathlib import Path
49+
50+
p = Path("transifex-util.py")
51+
old = '_call("make -C cpython/Doc/ gettext")'
52+
new = '_call("make -C cpython/Doc/ JOBS=1 gettext || make -C cpython/Doc/ JOBS=1 build BUILDER=gettext")'
53+
s = p.read_text()
54+
if old not in s:
55+
raise SystemExit("Expected pattern was not found in transifex-util.py")
56+
p.write_text(s.replace(old, new))
57+
PY
4858
grep -n "JOBS=1" transifex-util.py
4959
- run: ./transifex-util.py recreate_tx_config --language ru --project-slug python-newest --version ${{ matrix.version }}
5060
env:

0 commit comments

Comments
 (0)