GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update merge.py and Update Doc action · python/python-docs-tr@555f023

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • update_doc.yml
  • merge.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/update_doc.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/update_doc.yml
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ jobs:
2525
- name: Run merge.py
2626
run: python merge.py ${GITHUB_REF##*/}
2727

28+
- name: Commit changes
29+
run: |
30+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
31+
git config --local user.name "github-actions[bot]"
32+
git commit -m "Get changes from CPython Doc for ${{ github.ref_name }}"
33+
2834
- name: Create Pull Request
2935
uses: peter-evans/[email protected]
3036
with:
Collapse file

‎merge.py‎

Copy file name to clipboardExpand all lines: merge.py
+24-2Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
"""Tool to merge cpython pot files to python-docs-tr po files for a
22
given branch.
3+
4+
A CPython clone present in the venv/ directory is required if the --cpython_repo is not specified.
5+
6+
This script is run automatically by the GitHub Actions workflow every first day of the month.
37
"""
48

59
import re
610
import shutil
7-
from pathlib import Path
811
import argparse
912
import subprocess
13+
from pathlib import Path
1014
from subprocess import PIPE
1115
from tqdm import tqdm
1216

@@ -91,6 +95,23 @@ def update_makefile(cpython_repo: Path) -> None:
9195
run("git", "add", "Makefile")
9296

9397

98+
def git_add_relevant_files():
99+
"""Add only files with relevant modifications.
100+
101+
This only add files with actual modifications, not just metadata
102+
modifications, to avoid noise in history.
103+
"""
104+
modified_files = run("git", "ls-files", "-m", stdout=PIPE).stdout.split("\n")
105+
modified_po_files = [line for line in modified_files if line.endswith(".po")]
106+
for file in modified_po_files:
107+
diff = run("git", "diff", "-U0", file, stdout=PIPE).stdout
108+
if len(diff.split("\n")) > 8:
109+
run("git", "add", file)
110+
else:
111+
run("git", "checkout", "--", file)
112+
run("rm", "-f", "whatsnew/changelog.po") # We don't translate this file.
113+
114+
94115
def main():
95116
args = parse_args()
96117
setup_repo(args.cpython_repo, args.branch)
@@ -106,8 +127,9 @@ def main():
106127
remove_old_files(downstream - upstream)
107128
clean_paths((upstream - downstream) | (upstream & downstream))
108129
shutil.rmtree(pot_path)
109-
run("powrap", "-m")
130+
run("powrap", "*.po", "*/*.po")
110131
update_makefile(args.cpython_repo)
132+
git_add_relevant_files()
111133

112134

113135
if __name__ == "__main__":

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.