Skip to content

Commit 6b9f3a3

Browse files
authored
Merge branch '3.12' into library/math
2 parents 7d256e0 + cbc3bcf commit 6b9f3a3

File tree

235 files changed

+21553
-19688
lines changed

Some content is hidden

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

235 files changed

+21553
-19688
lines changed

.github/workflows/summarize_progress.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
jobs:
88
ci:
9+
if: github.repository == 'python/python-docs-zh-tw'
910
runs-on: ubuntu-latest
1011
permissions:
1112
# Give the default GITHUB_TOKEN write permission to commit and push the
@@ -32,7 +33,7 @@ jobs:
3233

3334
- name: Copy content
3435
run: |
35-
cp .scripts/summarize_progress/dist/summarize_progress.md markdown/各檔案翻譯進度清單.md
36+
cp .scripts/summarize_progress/result.md markdown/各檔案翻譯進度清單.md
3637
shell: bash
3738

3839
- name: Commit wiki code

.scripts/poetry.lock

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.scripts/summarize_progress/dist/summarize_progress.md

Lines changed: 0 additions & 498 deletions
This file was deleted.

.scripts/summarize_progress/main.py

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import re
22
import polib
33
import glob
4-
import datetime
54
import requests
65

76
from pathlib import Path
@@ -23,7 +22,7 @@ def entry_check(pofile: polib.POFile) -> str:
2322
lines_all = lines_tranlated + lines_untranlated
2423
progress = lines_tranlated / lines_all
2524
progress_percentage = round(progress * 100, 2)
26-
result = f"Ongoing, {progress_percentage} %"
25+
result = f"{progress_percentage} %"
2726

2827
return result
2928

@@ -51,9 +50,11 @@ def get_github_issues() -> list:
5150
5251
Steps:
5352
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
53+
2. Filter the issue if it have no "Translate" in the title
54+
3. Filter the issue if it have no correct filepath in the title
55+
56+
Expected Output:
57+
[ ((dirname, filename), assignee_id, issue_url), ... ]
5758
'''
5859
NUMBER_OF_ISSUES = get_open_issues_count()
5960

@@ -67,31 +68,41 @@ def get_github_issues() -> list:
6768

6869
result_list = []
6970
for issue in result["items"]:
70-
if issue["assignee"] is None:
71-
continue
71+
assignee = issue["assignee"]["login"] if issue["assignee"] else ""
7272

7373
title = issue["title"]
7474
if "翻譯" not in title and "translate" not in title.lower():
7575
continue
7676

77-
match = re.search("(?P<dirname>[^\s`][a-zA-z-]+)/(?P<filename>[a-zA-Z0-9._-]+(.po)?)", title)
77+
match = re.search(
78+
"(?P<dirname>[^\s`][a-zA-z-]+)/(?P<filename>[a-zA-Z0-9._-]+(.po)?)", title)
7879
if not match:
7980
continue
8081

8182
dirname, filename = match.group('dirname', 'filename')
8283
if not filename.endswith('.po'):
8384
filename += '.po'
8485

85-
result_list.append(((dirname, filename), issue["assignee"]["login"]))
86+
result_list.append(((dirname, filename), assignee, issue["html_url"]))
8687

8788
return result_list
8889

89-
def format_line_file(filename: str, result: str) -> str:
90-
return f" - {filename.ljust(37, '-')}{result}\r\n"
90+
91+
def format_line_table_header() -> list:
92+
return [f"|Filename|Progress|Issue|Assignee|\r\n",
93+
f"|-------:|:-------|:----|:-------|\r\n"]
94+
95+
96+
def format_issue_link(url: str) -> str:
97+
return f"[{url.split('/')[-1]}]({url})" if len(url) > 0 else ''
98+
99+
100+
def format_line_file(filename: str, data: dict) -> str:
101+
return f"|`{filename}`|{data['progress']}|{format_issue_link(data['issue'])}|{data['assignee']}|\r\n"
91102

92103

93104
def format_line_directory(dirname: str) -> str:
94-
return f"- {dirname}/\r\n"
105+
return f"## {dirname}\r\n"
95106

96107

97108
if __name__ == "__main__":
@@ -108,17 +119,27 @@ def format_line_directory(dirname: str) -> str:
108119
filename = path.name
109120
dirname = path.parent.name if path.parent.name != BASE_DIR.name else '/'
110121
po = polib.pofile(filepath)
111-
summary.setdefault(dirname, {})[filename] = entry_check(po)
122+
123+
summary.setdefault(dirname, {})[filename] = {
124+
'progress': entry_check(po),
125+
'issue': '',
126+
'assignee': '',
127+
}
112128

113129
'''
114130
Unpack the open issue list, and add assignee after the progress
115131
'''
116-
for (category, filename), assignee in issue_list:
132+
for (category, filename), assignee, issue_url in issue_list:
117133
try:
118-
summary[category][filename] += f", 💻 {assignee}"
134+
summary[category][filename]['issue'] = issue_url
135+
summary[category][filename]['assignee'] = assignee
119136
except KeyError:
120137
pass
121138

139+
'''
140+
Adding Space for Formatting Markdown Link
141+
'''
142+
122143
'''
123144
Format the lines that will write into the markdown file,
124145
also sort the directory name and file name.
@@ -127,12 +148,14 @@ def format_line_directory(dirname: str) -> str:
127148
summary_sorted = dict(sorted(summary.items()))
128149
for dirname, filedict in summary_sorted.items():
129150
writeliner.append(format_line_directory(dirname))
151+
writeliner.extend(format_line_table_header())
152+
130153
filedict_sorted = dict(sorted(filedict.items()))
131-
for filename, result in filedict_sorted.items():
132-
writeliner.append(format_line_file(filename, result))
154+
for filename, filedata in filedict_sorted.items():
155+
writeliner.append(format_line_file(filename, filedata))
133156

134157
with open(
135-
f"summarize_progress/dist/summarize_progress.md",
158+
f"summarize_progress/result.md",
136159
"w",
137160
) as file:
138161
file.writelines(writeliner)

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an
5353
for file in *.po */*.po; do ln -f $$file $(LC_MESSAGES)/$$file; done
5454
. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE)
5555

56+
.PHONY: build
57+
build: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone ## Automatically build an html local version
58+
@$(eval target=$(filter-out $@,$(MAKECMDGOALS)))
59+
@if [ -z $(target) ]; then \
60+
echo "\x1B[1;31m""Please provide a file argument.""\x1B[m"; \
61+
exit 1; \
62+
fi
63+
@if [ "$(suffix $(target))" != ".po" ]; then \
64+
echo "\x1B[1;31m""Incorrect file extension. Only '.po' files are allowed.""\x1B[m"; \
65+
exit 1; \
66+
fi
67+
@if [[ ! -f "$(target)" ]] ; then \
68+
echo "\x1B[1;31m""ERROR: $(target) not exist.""\x1B[m"; \
69+
exit 1; \
70+
fi
71+
@mkdir -p $(LC_MESSAGES)
72+
@$(eval dir=`echo $(target) | xargs -n1 dirname`) ## Get dir
73+
# If the build target is in under directory
74+
# We should make direcotry in $(LC_MESSAGES) and link the file.
75+
@if [ $(dir) != "." ]; then \
76+
echo "mkdir -p $(LC_MESSAGES)/$(dir)"; \
77+
mkdir -p $(LC_MESSAGES)/$(dir); \
78+
echo "ln -f ./$(target) $(LC_MESSAGES)/$(target)"; \
79+
ln -f ./$(target) $(LC_MESSAGES)/$(target); \
80+
fi
81+
# Build
82+
@echo "----"
83+
@. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D language=$(LANGUAGE) -D locale_dirs=locales -D gettext_compact=0' SOURCES='$(basename $(target)).rst' html
84+
5685
help:
5786
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
5887

@@ -133,3 +162,7 @@ rm_cpython: ## Remove cloned cpython repo
133162
.PHONY: lint
134163
lint: $(VENV)/bin/sphinx-lint ## Run sphinx-lint
135164
$(VENV)/bin/sphinx-lint --enable default-role
165+
166+
# This allows us to accept extra arguments (by doing nothing when we get a job that doesn't match, rather than throwing an error)
167+
%:
168+
@:

bugs.po

Lines changed: 6 additions & 6 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-11-05 09:50+0000\n"
16+
"POT-Creation-Date: 2024-04-18 00:04+0000\n"
1717
"PO-Revision-Date: 2022-08-31 12:34+0800\n"
1818
"Last-Translator: Steven Hsu <[email protected]>\n"
1919
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -82,7 +82,7 @@ msgstr ""
8282
"(程式碼執行的錯誤可以寄到 [email protected])。「docs@」是一個由志工們"
8383
"所運行的郵寄清單;您的請求會被注意到,但可能需要一些時間才會被處理。"
8484

85-
#: ../../bugs.rst:33
85+
#: ../../bugs.rst:32
8686
msgid "`Documentation bugs`_"
8787
msgstr "`說明文件錯誤`_"
8888

@@ -92,7 +92,7 @@ msgid ""
9292
"tracker."
9393
msgstr "一系列已被提交至 Python 問題追蹤系統的有關說明文件的錯誤。"
9494

95-
#: ../../bugs.rst:36
95+
#: ../../bugs.rst:35
9696
msgid "`Issue Tracking <https://devguide.python.org/tracker/>`_"
9797
msgstr "`問題追蹤系統 <https://devguide.python.org/tracker/>`_"
9898

@@ -101,7 +101,7 @@ msgid ""
101101
"Overview of the process involved in reporting an improvement on the tracker."
102102
msgstr "在追蹤系統上回報改進建議的過程簡介。"
103103

104-
#: ../../bugs.rst:39
104+
#: ../../bugs.rst:38
105105
msgid ""
106106
"`Helping with Documentation <https://devguide.python.org/docquality/#helping-"
107107
"with-documentation>`_"
@@ -209,7 +209,7 @@ msgstr ""
209209
"每一份問題報告都會被一位開發人員查核,並由他決定要做出什麼變更來修正這個問"
210210
"題。每當該問題有修正動作時,您會收到更新回報。"
211211

212-
#: ../../bugs.rst:89
212+
#: ../../bugs.rst:87
213213
msgid ""
214214
"`How to Report Bugs Effectively <https://www.chiark.greenend.org.uk/"
215215
"~sgtatham/bugs.html>`_"
@@ -225,7 +225,7 @@ msgstr ""
225225
"這篇文章詳細說明如何建立一份有用的錯誤報告。它描述了什麼樣的資訊是有用的,以"
226226
"及這些資訊為什麼有用。"
227227

228-
#: ../../bugs.rst:92
228+
#: ../../bugs.rst:91
229229
msgid ""
230230
"`Bug Writing Guidelines <https://bugzilla.mozilla.org/page.cgi?id=bug-"
231231
"writing.html>`_"

0 commit comments

Comments
 (0)