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

Commitdbcb050

Browse files
authored
Merge branch '3.12' into library/pickletools
2 parents362588b +30e1394 commitdbcb050

File tree

247 files changed

+29769
-28101
lines changed

Some content is hidden

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

247 files changed

+29769
-28101
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: 235 additions & 96 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.
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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ $(VENV)/bin/activate:
6969
$(VENV)/bin/sphinx-build:$(VENV)/bin/activate
7070
.$(VENV)/bin/activate; python3 -m pip install sphinx python-docs-theme
7171

72+
$(VENV)/bin/sphinx-lint:$(VENV)/bin/activate
73+
.$(VENV)/bin/activate; python3 -m pip install sphinx-lint
7274

7375
$(VENV)/bin/blurb:$(VENV)/bin/activate
7476
.$(VENV)/bin/activate; python3 -m pip install blurb
7577

7678

7779
.PHONY: upgrade_venv
7880
upgrade_venv:$(VENV)/bin/activate## Upgrade the venv that compiles the doc
79-
.$(VENV)/bin/activate; python3 -m pip install --upgrade sphinx python-docs-theme blurb
81+
.$(VENV)/bin/activate; python3 -m pip install --upgrade sphinx python-docs-theme blurb sphinx-lint
8082

8183

8284
.PHONY: progress
@@ -105,10 +107,7 @@ endif
105107
mkdir -p "$$(dirname "$$PO")";\
106108
if [ -f "$$PO" ];\
107109
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\
110+
msgmerge --lang=$(LANGUAGE) --backup=off --force-po -U "$$PO" "$$POT";\
112111
else\
113112
msgcat --lang=$(LANGUAGE) -o "$$PO" "$$POT";\
114113
fi\
@@ -130,3 +129,7 @@ fuzzy: ## Find fuzzy strings
130129
.PHONY: rm_cpython
131130
rm_cpython:## Remove cloned cpython repo
132131
rm -rf$(CPYTHON_CLONE)
132+
133+
.PHONY: lint
134+
lint:$(VENV)/bin/sphinx-lint## Run sphinx-lint
135+
$(VENV)/bin/sphinx-lint --enable default-role

‎README.rst‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ the PSF for inclusion in the documentation.
123123
.. _GitHub Flow:https://guides.github.com/introduction/flow/
124124

125125
首先,`新增一個 issue<https://github.com/python/python-docs-zh-tw/issues>`_\
126-
,如:「翻譯 tutorial/introduction.po」,讓大家知道你正在翻譯這個檔案。可以使用 `make todo` 列出尚待翻譯的檔案。
126+
,如:「翻譯 tutorial/introduction.po」,讓大家知道你正在翻譯這個檔案。可以使用 ``make todo`` 列出尚待翻譯的檔案。
127127

128128
接著在 terminal 裡按照以下步驟:
129129

@@ -138,12 +138,18 @@ the PSF for inclusion in the documentation.
138138

139139
poedit glossary.po
140140

141-
3. 存檔以後,執行以下列指令編譯輸出文件,以確保你的修改沒有rST 的語法錯誤或警告 ::
141+
3. 存檔以後,執行以下列指令編譯輸出完整文件,以確保你的修改沒有reST 的語法錯誤或警告 ::
142142

143143
VERSION=3.12 make all
144144

145+
或者只想快速檢查是否有 reST 語法錯誤 ::
146+
147+
VERSION=3.12 make lint
148+
149+
確保輸出中沒有任何關於正在翻譯的檔案的警告訊息。
150+
145151
如果你還沒有執行 `維護、預覽`_ 的 clone CPython 的動作,此指令會自動幫你 clone CPython,\
146-
並且會使用 Sphinx 幫你檢查rST 語法錯誤,我們盡量保持沒有 warning \
152+
並且會使用 Sphinx 幫你檢查reST 語法錯誤,我們盡量保持沒有 warning \
147153
的狀態,因此如果有出現 warning 的話請修復它。另外也記得檢查是否符合\
148154
`翻譯守則`_
149155

@@ -252,11 +258,11 @@ po 檔皆為首要的翻譯對象。你也可以幫忙校對已經翻譯過的
252258
- 在本情況使用 ``zip(*[iter(x)]*n)`` 是很常見的情況(Python 慣例)。
253259
- 在超文件標示語言 (HTML) 中應注意跳脫符號。
254260

255-
rST 語法注意事項
261+
reST 語法注意事項
256262
----------------
257263

258-
- ``:xxx:`...``` 即為rST 的語法,應該在譯文中保留。
259-
-rST 諸多語法需要保留前後的空白。在中文裡,該空白可以用:literal:`\\\\`
264+
- ``:xxx:`...``` 即為reST 的語法,應該在譯文中保留。
265+
-reST 諸多語法需要保留前後的空白。在中文裡,該空白可以用:literal:`\\\\`
260266
來取代,製造一個沒有寬度的分隔符號。
261267

262268
例如:
@@ -322,8 +328,8 @@ rST 語法注意事項
322328
術語表 Glossary
323329
===============
324330

325-
為了讓翻譯保持統一,我們整理了一份`術語列表
326-
<https://github.com/python/python-docs-zh-tw/wiki/%E8%A1%93%E8%AA%9E%E5%88%97%E8%A1%A8>`_ \
331+
為了讓翻譯保持統一,我們整理了一份\
332+
`術語列表<https://github.com/python/python-docs-zh-tw/wiki/%E8%A1%93%E8%AA%9E%E5%88%97%E8%A1%A8>`_ \
327333
如果翻譯過程中你覺得需要術語列表有所缺漏,請至 `Discussion \
328334
<https://github.com/python/python-docs-zh-tw/discussions>`_ 開啟新的討論補充術語。\
329335
新增的術語,將會於每次 Sprint 中共同討論是否合併進術語列表。

‎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