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

Commit813de09

Browse files
authored
feat: add create issue link to summary table
1 parente367c7f commit813de09

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

‎.scripts/summarize_progress/main.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@
66
frompathlibimportPath
77

88

9-
defentry_check(pofile:polib.POFile)->str:
9+
defget_progress(pofile:polib.POFile)->float:
1010
'''
1111
Check the po file with how many entries are translated or not.
1212
'''
1313

1414
lines_tranlated=len(pofile.translated_entries())
1515
lines_untranlated=len(pofile.untranslated_entries())
1616

17-
iflines_tranlated==0:
18-
result="❌"
19-
eliflines_untranlated==0:
20-
result="✅"
21-
else:
22-
lines_all=lines_tranlated+lines_untranlated
23-
progress=lines_tranlated/lines_all
24-
progress_percentage=round(progress*100,2)
25-
result=f"{progress_percentage} %"
26-
27-
returnresult
17+
# if lines_tranlated == 0:
18+
# result = "❌"
19+
# elif lines_untranlated == 0:
20+
# result = "✅"
21+
# else:
22+
lines_all=lines_tranlated+lines_untranlated
23+
progress=lines_tranlated/lines_all
24+
progress_percentage=round(progress*100,2)
25+
returnprogress_percentage
2826

2927

3028
defget_open_issues_count()->int:
@@ -93,13 +91,21 @@ def format_line_table_header() -> list:
9391
f"|-------:|:-------|:----|:-------|\r\n"]
9492

9593

96-
defformat_issue_link(url:str)->str:
97-
returnf"[{url.split('/')[-1]}]({url})"iflen(url)>0else''
94+
defformat_line_po_issue_display(issue_link:str,issue_number:str,create_issue_link:str,progress:float)->str:
95+
ifissue_link:
96+
returnf"[{issue_number}]({issue_link})"
97+
ifprogress!=100:
98+
returnf"[create issue]({create_issue_link})"
99+
return""
98100

99101

100-
defformat_line_file(dirname:str,filename:str,data:dict)->str:
101-
returnf"|[`{filename}`](https://github.com/python/python-docs-zh-tw/tree/3.13/{dirname}/{filename})"+ \
102-
f"|{data['progress']}|{format_issue_link(data['issue'])}|{data['assignee']}|\r\n"
102+
defformat_line_po(filename:str,po_link:str,progress:str,issue_display:str,assignee:str)->str:
103+
progress_display=f"{progress} %"
104+
ifprogress==0:
105+
progress_display="❌"
106+
elifprogress==100:
107+
progress_display="✅"
108+
returnf"|[`{filename}`]({po_link})|{progress_display}|{issue_display}|{assignee}|\r\n"
103109

104110

105111
defformat_line_directory(dirname:str)->str:
@@ -122,7 +128,7 @@ def format_line_directory(dirname: str) -> str:
122128
po=polib.pofile(filepath)
123129

124130
summary.setdefault(dirname, {})[filename]= {
125-
'progress':entry_check(po),
131+
'progress':get_progress(po),
126132
'issue':'',
127133
'assignee':'',
128134
}
@@ -153,7 +159,14 @@ def format_line_directory(dirname: str) -> str:
153159

154160
filedict_sorted=dict(sorted(filedict.items()))
155161
forfilename,filedatainfiledict_sorted.items():
156-
writeliner.append(format_line_file(dirname,filename,filedata))
162+
file_path=f"{dirname}/{filename}"
163+
po_link=f"https://github.com/python/python-docs-zh-tw/tree/3.13/{file_path}"
164+
issue_link=filedata['issue']
165+
issue_number=f"#{issue_link.split('/')[-1]}"
166+
create_issue_link=f"https://github.com/python/python-docs-zh-tw/issues/new?title=Translate `{file_path}`"
167+
issue_display=format_line_po_issue_display(issue_link,issue_number,filedata['progress'],create_issue_link)
168+
line_po=format_line_po(filename,po_link,filedata['progress'],issue_display,filedata['assignee'])
169+
writeliner.append(line_po)
157170

158171
withopen(
159172
f"summarize_progress/result.md",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp