Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7951fd2

Browse files
authored
Merge branch 'python:3.12' into 3.12
2 parentsf2a94b3 +8fef8f1 commit7951fd2

File tree

178 files changed

+19108
-18614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+19108
-18614
lines changed

‎.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
run:sudo apt-get install gettext
1414

1515
-name:Validate
16-
run:VERSION=${{ github.event.pull_request.base.ref }} MODE=dummy make all
16+
run:VERSION=${{ github.event.repository.default_branch }} MODE=dummy make all
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name:summarize_progress
2+
3+
on:
4+
schedule:
5+
-cron:'30 23 * * 5'
6+
7+
jobs:
8+
ci:
9+
runs-on:ubuntu-latest
10+
permissions:
11+
# Give the default GITHUB_TOKEN write permission to commit and push the
12+
# added or changed files to the repository.
13+
contents:write
14+
steps:
15+
-uses:actions/checkout@v2
16+
17+
-name:Install poetry
18+
uses:abatilo/actions-poetry@v2
19+
20+
-name:Execute Check Process
21+
run:|
22+
chmod +x .scripts/summarize_progress.sh
23+
.scripts/summarize_progress.sh
24+
shell:bash
25+
26+
-uses:stefanzweifel/git-auto-commit-action@v5
27+
with:
28+
commit_message:Weekly Update -- Summarize Progress

‎.scripts/poetry.lock

Lines changed: 140 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎.scripts/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ python = "^3.10"
1010
polib ="1.1.1"
1111
googletrans ="3.1.0a0"
1212
translate-toolkit ="3.8.1"
13-
13+
requests ="2.31.0"
1414

1515
[build-system]
1616
requires = ["poetry-core"]

‎.scripts/summarize_progress.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
WORK_DIR=.scripts
4+
cd$WORK_DIR
5+
6+
source utils/install_poetry.sh
7+
8+
poetry lock
9+
poetry install
10+
poetry run bash -c"
11+
python summarize_progress/main.py
12+
"

‎.scripts/summarize_progress/dist/summarize_progress.md

Lines changed: 498 additions & 0 deletions
Large diffs are not rendered by default.

‎.scripts/summarize_progress/main.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
importre
2+
importpolib
3+
importglob
4+
importdatetime
5+
importrequests
6+
7+
frompathlibimportPath
8+
9+
10+
defentry_check(pofile:polib.POFile)->str:
11+
'''
12+
Check the po file with how many entries are translated or not.
13+
'''
14+
15+
lines_tranlated=len(pofile.translated_entries())
16+
lines_untranlated=len(pofile.untranslated_entries())
17+
18+
iflines_tranlated==0:
19+
result="❌"
20+
eliflines_untranlated==0:
21+
result="✅"
22+
else:
23+
lines_all=lines_tranlated+lines_untranlated
24+
progress=lines_tranlated/lines_all
25+
progress_percentage=round(progress*100,2)
26+
result=f"Ongoing,{progress_percentage} %"
27+
28+
returnresult
29+
30+
31+
defget_open_issues_count()->int:
32+
'''
33+
Fetch GitHub API to get the number of OPEN ISSUES.
34+
'''
35+
36+
url=f"https://api.github.com/search/issues?q=repo:python/python-docs-zh-tw+type:issue+state:open"
37+
headers= {
38+
"Accept":"application/vnd.github+json",
39+
"X-GitHub-Api-Version":"2022-11-28",
40+
}
41+
r=requests.get(url=url,headers=headers)
42+
result=r.json()
43+
44+
returnresult["total_count"]
45+
46+
47+
defget_github_issues()->list:
48+
'''
49+
Fetch GitHub API to collect the infomation of OPEN ISSUES,
50+
including issue title and assignee.
51+
52+
Steps:
53+
1. Fetch GitHub API and get open issue list
54+
2. Filter the issue if it have no assignee
55+
3. Filter the issue if it have no "Translate" in the title
56+
4. Filter the issue if it have no correct filepath in the title
57+
'''
58+
NUMBER_OF_ISSUES=get_open_issues_count()
59+
60+
url=f"https://api.github.com/search/issues?q=repo:python/python-docs-zh-tw+type:issue+state:open&per_page={NUMBER_OF_ISSUES}"
61+
headers= {
62+
"Accept":"application/vnd.github+json",
63+
"X-GitHub-Api-Version":"2022-11-28",
64+
}
65+
r=requests.get(url=url,headers=headers)
66+
result=r.json()
67+
68+
result_list= []
69+
forissueinresult["items"]:
70+
ifissue["assignee"]isNone:
71+
continue
72+
73+
title=issue["title"]
74+
if"翻譯"notintitleand"translate"notintitle.lower():
75+
continue
76+
77+
match=re.search("(?P<dirname>[^\s`][a-zA-z-]+)/(?P<filename>[a-zA-Z0-9._-]+(.po)?)",title)
78+
ifnotmatch:
79+
continue
80+
81+
dirname,filename=match.group('dirname','filename')
82+
ifnotfilename.endswith('.po'):
83+
filename+='.po'
84+
85+
result_list.append(((dirname,filename),issue["assignee"]["login"]))
86+
87+
returnresult_list
88+
89+
defformat_line_file(filename:str,result:str)->str:
90+
returnf" -{filename.ljust(37,'-')}{result}\r\n"
91+
92+
93+
defformat_line_directory(dirname:str)->str:
94+
returnf"-{dirname}/\r\n"
95+
96+
97+
if__name__=="__main__":
98+
issue_list=get_github_issues()
99+
100+
'''
101+
Search all the po file in the directory,
102+
and record the translation progress of each files.
103+
'''
104+
BASE_DIR=Path("../")
105+
summary= {}
106+
forfilepathinglob.glob(str(BASE_DIR/"**/*.po"),recursive=True):
107+
path=Path(filepath)
108+
filename=path.name
109+
dirname=path.parent.nameifpath.parent.name!=BASE_DIR.nameelse'/'
110+
po=polib.pofile(filepath)
111+
summary.setdefault(dirname, {})[filename]=entry_check(po)
112+
113+
'''
114+
Unpack the open issue list, and add assignee after the progress
115+
'''
116+
for (category,filename),assigneeinissue_list:
117+
try:
118+
summary[category][filename]+=f", 💻{assignee}"
119+
exceptKeyError:
120+
pass
121+
122+
'''
123+
Format the lines that will write into the markdown file,
124+
also sort the directory name and file name.
125+
'''
126+
writeliner= []
127+
summary_sorted=dict(sorted(summary.items()))
128+
fordirname,filedictinsummary_sorted.items():
129+
writeliner.append(format_line_directory(dirname))
130+
filedict_sorted=dict(sorted(filedict.items()))
131+
forfilename,resultinfiledict_sorted.items():
132+
writeliner.append(format_line_file(filename,result))
133+
134+
withopen(
135+
f"summarize_progress/dist/summarize_progress.md",
136+
"w",
137+
)asfile:
138+
file.writelines(writeliner)

‎Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ endif
105105
mkdir -p "$$(dirname "$$PO")";\
106106
if [ -f "$$PO" ];\
107107
then\
108-
case "$$POT" in\
109-
*whatsnew*) msgmerge --lang=$(LANGUAGE) --backup=off --force-po --no-fuzzy-matching -U "$$PO" "$$POT" ;;\
110-
*) msgmerge --lang=$(LANGUAGE) --backup=off --force-po -U "$$PO" "$$POT" ;;\
111-
esac\
108+
msgmerge --lang=$(LANGUAGE) --backup=off --force-po -U "$$PO" "$$POT";\
112109
else\
113110
msgcat --lang=$(LANGUAGE) -o "$$PO" "$$POT";\
114111
fi\

‎bugs.po

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ msgid ""
1313
msgstr ""
1414
"Project-Id-Version:Python 3.12\n"
1515
"Report-Msgid-Bugs-To:\n"
16-
"POT-Creation-Date:2023-02-27 00:17+0000\n"
16+
"POT-Creation-Date:2023-11-05 09:50+0000\n"
1717
"PO-Revision-Date:2022-08-31 12:34+0800\n"
1818
"Last-Translator:Steven Hsu <hsuhaochun@gmail.com>\n"
1919
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -117,9 +117,10 @@ msgstr "給有意成為 Python 說明文件貢獻者的綜合指南。"
117117

118118
#:../../bugs.rst:41
119119
msgid""
120-
"`Documentation Translations <https://devguide.python.org/documenting/"
121-
"#translating>`_"
122-
msgstr"`說明文件翻譯 <https://devguide.python.org/documenting/#translating>`_"
120+
"`Documentation Translations <https://devguide.python.org/documentation/"
121+
"translating/>`_"
122+
msgstr""
123+
"`說明文件翻譯 <https://devguide.python.org/documentation/translating/>`_"
123124

124125
#:../../bugs.rst:42
125126
msgid""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp