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

Commita53ac79

Browse files
authored
New progress script + New translation (#144)
1 parent01e26b8 commita53ac79

File tree

6 files changed

+149
-13
lines changed

6 files changed

+149
-13
lines changed

‎.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
hooks:
2828
-id:black
2929
name:Run black on Python files
30-
args:["--line-length=140", "--target-version=py311"]
30+
args:["--target-version=py311"]
3131
files:\.py$
3232

3333
-repo:https://github.com/pre-commit/pre-commit-hooks

‎includes/wasm-notavail.po

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,30 @@
22
# Copyright (C) 2001-2023, Python Software Foundation
33
# This file is distributed under the same license as the Python package.
44
#
5-
#,fuzzy
65
msgid ""
76
msgstr ""
87
"Project-Id-Version:Python 3.11\n"
98
"Report-Msgid-Bugs-To:\n"
109
"POT-Creation-Date:2023-03-01 00:18+0000\n"
11-
"PO-Revision-Date:YEAR-MO-DA HO:MI+ZONE\n"
10+
"PO-Revision-Date:2023-05-02 12:49+0300\n"
1211
"Last-Translator:\n"
1312
"Language-Team:TURKISH <python.docs.tr@gmail.com>\n"
1413
"Language:tr\n"
1514
"MIME-Version:1.0\n"
1615
"Content-Type:text/plain; charset=UTF-8\n"
1716
"Content-Transfer-Encoding:8bit\n"
17+
"X-Generator:Poedit 3.2.2\n"
1818

1919
#:includes/wasm-notavail.rst:3
2020
msgid":ref:`Availability <availability>`: not Emscripten, not WASI."
21-
msgstr""
21+
msgstr":ref:`Kullanılabilirlik <availability>`: Emscripten değil, WASI değil."
2222

2323
#:includes/wasm-notavail.rst:5
2424
msgid""
2525
"This module does not work or is not available on WebAssembly platforms "
2626
"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for "
2727
"more information."
2828
msgstr""
29+
"Bu modül WebAssembly platformları olan ``wasm32-emscripten`` ve ``wasm32-"
30+
"wasi`` üzerinde çalışmaz veya kullanılamaz. Daha fazla bilgi için :ref:`wasm-"
31+
"availability` sayfasına bakın."

‎merge.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def update_makefile(cpython_repo: Path) -> None:
8585
used to generate the `po` files.
8686
"""
8787
makefile=Path("Makefile").read_text(encoding="UTF-8")
88-
head=run("git","-C",cpython_repo,"rev-parse","HEAD",stdout=PIPE).stdout.strip()
88+
head=run(
89+
"git","-C",cpython_repo,"rev-parse","HEAD",stdout=PIPE
90+
).stdout.strip()
8991
makefile=re.sub(
9092
"^CPYTHON_CURRENT_COMMIT :=.*$",
9193
f"CPYTHON_CURRENT_COMMIT :={head}",
@@ -121,8 +123,14 @@ def main():
121123
cwd=args.cpython_repo/"Doc",
122124
)
123125
pot_path=args.cpython_repo/"pot"
124-
upstream= {file.relative_to(pot_path).with_suffix(".po")forfileinpot_path.glob("**/*.pot")}
125-
downstream= {Path(po)forpoinrun("git","ls-files","*.po",stdout=PIPE).stdout.splitlines()}
126+
upstream= {
127+
file.relative_to(pot_path).with_suffix(".po")
128+
forfileinpot_path.glob("**/*.pot")
129+
}
130+
downstream= {
131+
Path(po)
132+
forpoinrun("git","ls-files","*.po",stdout=PIPE).stdout.splitlines()
133+
}
126134
copy_new_files(upstream-downstream,pot_path=pot_path)
127135
update_known_files(upstream&downstream,pot_path=pot_path)
128136
remove_old_files(downstream-upstream)

‎scripts/format_check.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
importpolib
99

1010
parser=argparse.ArgumentParser()
11-
parser.add_argument("subject",nargs="?",default=None,help="Subject to check (file or directory)")
11+
parser.add_argument(
12+
"path",
13+
nargs="?",
14+
default=None,
15+
help="Path to the .po file or directory containing .po files",
16+
)
1217
parser.add_argument("-t","--threshold",type=int,default=85)
1318
args=parser.parse_args()
1419

@@ -28,7 +33,11 @@
2833

2934
elifos.path.isfile(args.subject):
3035
is_file=True
31-
subject=args.subjectifos.path.isabs(args.subject)elseos.path.join(subject,args.subject)
36+
subject= (
37+
args.subject
38+
ifos.path.isabs(args.subject)
39+
elseos.path.join(subject,args.subject)
40+
)
3241

3342
else:
3443
print("Invalid subject, showing all files.")
@@ -56,7 +65,9 @@ def main(subject):
5665
wordsid= [wordforwordinentry.msgid.split()ifhas_delimiters(word)]
5766

5867
ifhas_delimiters(entry.msgstr):
59-
wordsstr= [wordforwordinentry.msgstr.split()ifhas_delimiters(word)]
68+
wordsstr= [
69+
wordforwordinentry.msgstr.split()ifhas_delimiters(word)
70+
]
6071

6172
iflen(wordsid)!=len(wordsstr):
6273
key=pofilename

‎scripts/progress.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
importos
2+
fromargparseimportArgumentParser
3+
fromfunctoolsimportlru_cache
4+
fromsubprocessimportcheck_output
5+
6+
importpolib
7+
8+
parser=ArgumentParser()
9+
parser.add_argument(
10+
"path",
11+
nargs="?",
12+
default=None,
13+
help="Path to the .po file or directory containing .po files",
14+
)
15+
parser.add_argument(
16+
"--no-cache",action="store_true",default=False,help="Don't use cache"
17+
)
18+
args=parser.parse_args()
19+
20+
21+
defmain():
22+
globalgit_root
23+
total_progress=False
24+
git_root=get_git_root()
25+
26+
ifargs.no_cache:
27+
progress.cache_clear()
28+
get_git_root.cache_clear()
29+
30+
ifargs.pathisNone:
31+
print("No path specified, showing total progress...")
32+
args.path=os.path.abspath(git_root).replace("\\","/")
33+
total_progress=True
34+
35+
else:
36+
args.path=os.path.abspath(args.path).replace("\\","/")
37+
38+
ifos.path.isfile(args.path):
39+
paths= [args.path]
40+
41+
elifos.path.isdir(args.path):
42+
paths= []
43+
forroot,_,filesinos.walk(args.path):
44+
paths.extend(
45+
os.path.join(root,file)forfileinfilesiffile.endswith(".po")
46+
)
47+
paths=map(lambdax:x.replace("\\","/"),paths)
48+
49+
else:
50+
print("Invalid path")
51+
return-1
52+
53+
try:
54+
progress(tuple(paths),total_progress)
55+
return0
56+
exceptExceptionase:
57+
print(f"Error:{e}")
58+
return-1
59+
60+
61+
@lru_cache(maxsize=512)
62+
defprogress(paths,total_progress=False):
63+
total=0
64+
translated=0
65+
previous="/"
66+
is_root=True
67+
forpathinpaths:
68+
pofile=polib.pofile(path)
69+
total+=len(pofile)-len(pofile.obsolete_entries())
70+
translated+=len(pofile.translated_entries())
71+
path=path.replace(f"{git_root}","")
72+
ifis_rootandlen(path.split("/"))==2:
73+
print()
74+
print("PYTHON-DOCS-TR")
75+
print("-"*14)
76+
is_root=False
77+
if (previous.split("/")[1]!=path.split("/")[1])andlen(path.split("/"))>2:
78+
print()
79+
print(path.split("/")[1].upper())
80+
print("-"*len(path.split("/")[1].upper()))
81+
previous=path
82+
print(f"{path}:{pofile.percent_translated()}%")
83+
84+
dir_path=args.path.replace(f"{git_root}","/").replace("//","/")
85+
total_progress_of="/"iftotal_progresselsedir_path
86+
print()
87+
print(
88+
f"Total progress of{total_progress_of}:{round(translated/total*100,2)}%"
89+
)iflen(paths)>1elseNone
90+
91+
92+
@lru_cache(maxsize=1)
93+
defget_git_root():
94+
returnos.path.abspath(
95+
check_output(["git","rev-parse","--show-toplevel"]).decode("utf-8").strip()
96+
).replace("\\","/")
97+
98+
99+
if__name__=="__main__":
100+
main()

‎scripts/translate.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99

1010
parser=ArgumentParser()
1111
parser.add_argument("filename",help="File to translate")
12-
parser.add_argument("-t","--translator",choices=["google","deepl"],default="deepl",help="Translator to use")
12+
parser.add_argument(
13+
"-t",
14+
"--translator",
15+
choices=["google","deepl"],
16+
default="deepl",
17+
help="Translator to use",
18+
)
1319
parser.add_argument(
1420
"-a",
1521
"--api-key",
@@ -18,7 +24,13 @@
1824
)
1925
parser.add_argument("-v","--verbose",action="store_true",help="Verbose mode")
2026
parser.add_argument("-d","--debug",action="store_true",help="Debug mode")
21-
parser.add_argument("-s","--skip-translated-entries",choices=[True,False],default=True,help="Skip already translated entries")
27+
parser.add_argument(
28+
"-s",
29+
"--skip-translated-entries",
30+
choices=[True,False],
31+
default=True,
32+
help="Skip already translated entries",
33+
)
2234

2335
args=parser.parse_args()
2436

@@ -117,7 +129,9 @@ def undo_sphinx_directives_protection(placeholders: dict, translated_text: str)
117129
ifargs.translator.lower()=="google":
118130
translator=GoogleTranslator(source="en",target="tr")
119131
elifargs.translator.lower()=="deepl":
120-
translator=DeeplTranslator(api_key=args.api_key,source="en",target="tr",use_free_api=True)
132+
translator=DeeplTranslator(
133+
api_key=args.api_key,source="en",target="tr",use_free_api=True
134+
)
121135
else:
122136
raiseValueError("Invalid translator")
123137

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp