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

Commitd3a7873

Browse files
committed
Update scripts
1 parent824e943 commitd3a7873

File tree

4 files changed

+51
-46
lines changed

4 files changed

+51
-46
lines changed

‎merge.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ def update_makefile(cpython_repo: Path) -> None:
8080
used to generate the `po` files.
8181
"""
8282
makefile=Path("Makefile").read_text(encoding="UTF-8")
83-
head=run(
84-
"git","-C",cpython_repo,"rev-parse","HEAD",stdout=PIPE
85-
).stdout.strip()
83+
head=run("git","-C",cpython_repo,"rev-parse","HEAD",stdout=PIPE).stdout.strip()
8684
makefile=re.sub(
8785
"^CPYTHON_CURRENT_COMMIT :=.*$",
8886
f"CPYTHON_CURRENT_COMMIT :={head}",
@@ -101,14 +99,8 @@ def main():
10199
cwd=args.cpython_repo/"Doc",
102100
)
103101
pot_path=args.cpython_repo/"pot"
104-
upstream= {
105-
file.relative_to(pot_path).with_suffix(".po")
106-
forfileinpot_path.glob("**/*.pot")
107-
}
108-
downstream= {
109-
Path(po)
110-
forpoinrun("git","ls-files","*.po",stdout=PIPE).stdout.splitlines()
111-
}
102+
upstream= {file.relative_to(pot_path).with_suffix(".po")forfileinpot_path.glob("**/*.pot")}
103+
downstream= {Path(po)forpoinrun("git","ls-files","*.po",stdout=PIPE).stdout.splitlines()}
112104
copy_new_files(upstream-downstream,pot_path=pot_path)
113105
update_known_files(upstream&downstream,pot_path=pot_path)
114106
remove_old_files(downstream-upstream)

‎requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
poutils
22
tqdm
3-
sphinx-lint
43
pre-commit
54
polib

‎scripts/format_check.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99

1010
parser=argparse.ArgumentParser()
11-
parser.add_argument(
12-
"subject",nargs="?",default=None,help="Subject to check (file or directory)"
13-
)
11+
parser.add_argument("subject",nargs="?",default=None,help="Subject to check (file or directory)")
1412
parser.add_argument("-t","--threshold",type=int,default=85)
1513
args=parser.parse_args()
1614

@@ -30,11 +28,7 @@
3028

3129
elifos.path.isfile(args.subject):
3230
is_file=True
33-
subject= (
34-
args.subject
35-
ifos.path.isabs(args.subject)
36-
elseos.path.join(subject,args.subject)
37-
)
31+
subject=args.subjectifos.path.isabs(args.subject)elseos.path.join(subject,args.subject)
3832

3933
else:
4034
print("Invalid subject, showing all files.")
@@ -62,9 +56,7 @@ def main(subject):
6256
wordsid= [wordforwordinentry.msgid.split()ifhas_delimiters(word)]
6357

6458
ifhas_delimiters(entry.msgstr):
65-
wordsstr= [
66-
wordforwordinentry.msgstr.split()ifhas_delimiters(word)
67-
]
59+
wordsstr= [wordforwordinentry.msgstr.split()ifhas_delimiters(word)]
6860

6961
iflen(wordsid)!=len(wordsstr):
7062
key=pofilename

‎scripts/progress.py

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77

88
parser=argparse.ArgumentParser()
9-
parser.add_argument(
10-
"subject",nargs="?",default=None,help="Subject to check (file or directory)"
11-
)
9+
parser.add_argument("subject",nargs="?",default=None,help="Subject to check (file or directory)")
1210
parser.add_argument("-c","--completed",action="store_true")
1311
parser.add_argument("-t","--threshold",type=int,default=90)
1412
args=parser.parse_args()
@@ -28,38 +26,62 @@
2826

2927
elifos.path.isfile(args.subject):
3028
is_file=True
31-
args.subject= (
32-
args.subject
33-
ifos.path.isabs(args.subject)
34-
elseos.path.join(PO_DIR,args.subject)
35-
)
29+
args.org_subject=args.subject
30+
args.subject=args.subjectifos.path.isabs(args.subject)elseos.path.join(PO_DIR,args.subject)
3631

3732
else:
3833
print("Invalid subject, showing all files.")
3934

4035

36+
defpo_stats(pofilename):
37+
po=polib.pofile(pofilename)
38+
translated=len(po.translated_entries())
39+
total=len(po)+translated
40+
return (po.percent_translated(),translated,total)
41+
42+
4143
defmain():
4244
files= []
45+
translated= []
46+
total= []
4347
ifis_file:
4448
po=polib.pofile(args.subject)
45-
return[[args.subject.replace(PO_DIR,""),po.percent_translated()]]
49+
returnos.path.relpath(args.org_subject),po.percent_translated()
4650

4751
forpofilenameinglob.glob(f"{PO_DIR}**/*.po"):
48-
po=polib.pofile(pofilename)
49-
files.append((pofilename.replace(PO_DIR,""),po.percent_translated()))
52+
stats=po_stats(pofilename)
53+
translated.append(stats[1])
54+
total.append(stats[2])
55+
files.append((os.path.relpath(pofilename).replace("\\","/"),stats[0]))
5056
forpofilenameinglob.glob(f"{PO_DIR}**/**/*.po"):
51-
po=polib.pofile(pofilename)
52-
files.append((pofilename.replace(PO_DIR,""),po.percent_translated()))
53-
returnfiles
57+
stats=po_stats(pofilename)
58+
translated.append(stats[1])
59+
total.append(stats[2])
60+
files.append((os.path.relpath(pofilename).replace("\\","/"),stats[0]))
61+
returnfiles,round(sum(translated)/sum(total)*100,1)
5462

5563

5664
if__name__=="__main__":
57-
results= [f"{file[0]}:{file[1]}%"forfileinmain()]
58-
59-
forresultinresults:
60-
ifargs.completedandint(result.split(" ")[1].replace("%",""))>min(
61-
args.threshold,100
62-
):
63-
print(result)
64-
elifnotargs.completed:
65-
print(result)
65+
files,weighted_progress=main()
66+
ifnotargs.subject:
67+
print("No subject provided, showing general progress")
68+
print(f"{len([fileforfileinfilesiffile[1]>min(args.threshold,100)])} /{len(files)} files completed")
69+
print(f"Weighted progress:{weighted_progress}%\n")
70+
71+
ifargs.completed:
72+
print("Completed files:")
73+
completed_files= [fileforfileinfilesiffile[1]>min(args.threshold,100)]
74+
forfile,percentageincompleted_files:
75+
print(f"{file}:{percentage}%")
76+
elifis_file:
77+
print(f"{files}:{weighted_progress}%")
78+
79+
else:
80+
print(f"{len([fileforfileinfilesiffile[1]>min(args.threshold,100)])} /{len(files)} files completed")
81+
print(f"Weighted progress:{weighted_progress}%\n")
82+
83+
ifargs.completed:
84+
print("Completed files:")
85+
completed_files= [fileforfileinfilesiffile[1]>min(args.threshold,100)]
86+
forfile,percentageincompleted_files:
87+
print(f"{file}:{percentage}%")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp