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

Commit3c56678

Browse files
authored
Merge branch '3.12' into library/hashlib
2 parents499e6cf +68c024f commit3c56678

File tree

367 files changed

+32356
-28710
lines changed

Some content is hidden

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

367 files changed

+32356
-28710
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: 173 additions & 109 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing 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
importre
22
importpolib
33
importglob
4-
importdatetime
54
importrequests
65

76
frompathlibimportPath
@@ -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
returnresult
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
forissueinresult["items"]:
70-
ifissue["assignee"]isNone:
71-
continue
71+
assignee=issue["assignee"]["login"]ifissue["assignee"]else""
7272

7373
title=issue["title"]
7474
if"翻譯"notintitleand"translate"notintitle.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
ifnotmatch:
7980
continue
8081

8182
dirname,filename=match.group('dirname','filename')
8283
ifnotfilename.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
returnresult_list
8889

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

92103

93104
defformat_line_directory(dirname:str)->str:
94-
returnf"-{dirname}/\r\n"
105+
returnf"##{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.nameifpath.parent.name!=BASE_DIR.nameelse'/'
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),assigneeinissue_list:
132+
for (category,filename),assignee,issue_urlinissue_list:
117133
try:
118-
summary[category][filename]+=f", 💻{assignee}"
134+
summary[category][filename]['issue']=issue_url
135+
summary[category][filename]['assignee']=assignee
119136
exceptKeyError:
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
fordirname,filedictinsummary_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-
forfilename,resultinfiledict_sorted.items():
132-
writeliner.append(format_line_file(filename,result))
154+
forfilename,filedatainfiledict_sorted.items():
155+
writeliner.append(format_line_file(filename,filedata))
133156

134157
withopen(
135-
f"summarize_progress/dist/summarize_progress.md",
158+
f"summarize_progress/result.md",
136159
"w",
137160
)asfile:
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
forfilein*.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+
@:

‎README.rst‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ the PSF for inclusion in the documentation.
8484
上請參考 https://gitforwindows.org/)
8585
- 一個 ``.po`` 檔的編輯器。推薦使用 `Poedit<https://poedit.net>`_,若熟悉 po 檔用一般文字編輯器亦可。
8686
- macOS 的使用者還需要先利用 `homebrew<https://brew.sh/index_zh-tw>`_ 安裝 gettext,屆時 Sphinx 會使用到。
87+
8788
..code-block::bash
8889
8990
brew install gettext
90-
9191
brew link gettext --force
92+
9293
- 安裝 pre-commit 自動在 commit 時檢查 ``.po`` 檔格式。
94+
9395
..code-block::bash
9496
9597
pip install pre-commit

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp