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

Commit15c239b

Browse files
authored
feat(summary): show string count
1 parenta7e006c commit15c239b

File tree

1 file changed

+41
-45
lines changed

1 file changed

+41
-45
lines changed

‎.scripts/summarize_progress/main.py‎

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

88

9-
defget_progress(pofile:polib.POFile)->float:
10-
'''
11-
Check the po file with how many entries are translated or not.
12-
'''
13-
14-
lines_tranlated=len(pofile.translated_entries())
15-
lines_untranlated=len(pofile.untranslated_entries())
16-
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
26-
27-
289
defget_open_issues_count()->int:
2910
'''
3011
Fetch GitHub API to get the number of OPEN ISSUES.
@@ -87,7 +68,7 @@ def get_github_issues() -> list:
8768

8869

8970
defformat_line_table_header()->list:
90-
return [f"|Filename|Progress|Issue|Assignee|\r\n",
71+
return [f"|Filename|Progress (#string)|Issue|Assignee|\r\n",
9172
f"|-------:|:-------|:----|:-------|\r\n"]
9273

9374

@@ -99,17 +80,11 @@ def format_line_po_issue_display(issue_link: str, issue_number: str, progress: f
9980
return""
10081

10182

102-
defformat_line_po(filename:str,po_link:str,progress:str,issue_display:str,assignee:str)->str:
83+
defformat_line_po(filename:str,po_link:str,progress:str,num_entries:str,issue_display:str,assignee:str)->str:
10384
progress_display=f"{progress} %"
104-
ifprogress==0:
105-
progress_display="❌"
106-
elifprogress==100:
85+
ifprogress==100:
10786
progress_display="✅"
108-
returnf"|[`{filename}`]({po_link})|{progress_display}|{issue_display}|{assignee}|\r\n"
109-
110-
111-
defformat_line_directory(dirname:str)->str:
112-
returnf"##{dirname}\r\n"
87+
returnf"|[`{filename}`]({po_link})|{progress_display} ({num_entries:,})|{issue_display}|{assignee}|\r\n"
11388

11489

11590
if__name__=="__main__":
@@ -124,11 +99,17 @@ def format_line_directory(dirname: str) -> str:
12499
forfilepathinglob.glob(str(BASE_DIR/"**/*.po"),recursive=True):
125100
path=Path(filepath)
126101
filename=path.name
127-
dirname=path.parent.nameifpath.parent.name!=BASE_DIR.nameelse'/'
102+
dirname=path.parent.nameifpath.parent.name!=BASE_DIR.nameelse'root'
128103
po=polib.pofile(filepath)
129104

105+
num_entries=len(list(filter(lambdae:note.obsolete(),po)))
106+
num_translated=len(po.translated_entries())
130107
summary.setdefault(dirname, {})[filename]= {
131-
'progress':get_progress(po),
108+
'po_info': {
109+
'num_entries':num_entries,
110+
'num_translated':num_translated,
111+
'progress':round(num_translated/num_entries*100,2),
112+
},
132113
'issue':'',
133114
'assignee':'',
134115
}
@@ -144,19 +125,15 @@ def format_line_directory(dirname: str) -> str:
144125
pass
145126

146127
'''
147-
Adding Space for Formatting Markdown Link
148-
'''
149-
150-
'''
151-
Format the lines that will write into the markdown file,
128+
Format the lines that will be written into the markdown file,
152129
also sort the directory name and file name.
153130
'''
154131
writeliner= []
155132
summary_sorted=dict(sorted(summary.items()))
133+
total_entries,total_translated=0,0
156134
fordirname,filedictinsummary_sorted.items():
157-
writeliner.append(format_line_directory(dirname))
158-
writeliner.extend(format_line_table_header())
159-
135+
dir_total_entries,dir_total_translated=0,0
136+
lines= []
160137
filedict_sorted=dict(sorted(filedict.items()))
161138
forfilename,filedatainfiledict_sorted.items():
162139
file_path=f"{dirname}/{filename}"ifdirnameelsefilename
@@ -165,11 +142,30 @@ def format_line_directory(dirname: str) -> str:
165142
issue_number=f"#{issue_link.split('/')[-1]}"
166143
create_issue_link=f"https://github.com/python/python-docs-zh-tw/issues/new?title=Translate%20`{file_path}`"
167144
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)
145+
line_po=format_line_po(
146+
filename,
147+
po_link,
148+
filedata['po_info']['progress'],
149+
filedata['po_info']['num_entries'],
150+
issue_display,
151+
filedata['assignee'],
152+
)
153+
lines.append(line_po)
154+
155+
dir_total_entries+=filedata['po_info']['num_entries']
156+
dir_total_translated+=filedata['po_info']['num_translated']
157+
158+
dir_progress=round(dir_total_translated/dir_total_entries*100,2)
159+
writeliner.append(f"##{dirname} ({dir_progress}%)\r\n")
160+
writeliner.extend(format_line_table_header())
161+
writeliner.extend(lines)
162+
163+
total_entries+=dir_total_entries
164+
total_translated+=dir_total_translated
165+
166+
overall_progress=round(total_translated/total_entries*100,2)
167+
title=f"## Overall Progress:{overall_progress}% ({total_translated:,} /{total_entries:,})\r\n"
168+
writeliner= [title]+writeliner
170169

171-
withopen(
172-
f"summarize_progress/result.md",
173-
"w",
174-
)asfile:
170+
withopen(f"summarize_progress/result.md","w")asfile:
175171
file.writelines(writeliner)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp