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

New progress script + New translation#144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
egeakman merged 2 commits into3.11fromprogress
May 2, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ repos:
hooks:
- id: black
name: Run black on Python files
args: ["--line-length=140", "--target-version=py311"]
args: ["--target-version=py311"]
files: \.py$

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
9 changes: 6 additions & 3 deletionsincludes/wasm-notavail.po
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,30 @@
# Copyright (C) 2001-2023, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-01 00:18+0000\n"
"PO-Revision-Date:YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date:2023-05-02 12:49+0300\n"
"Last-Translator: \n"
"Language-Team: TURKISH <python.docs.tr@gmail.com>\n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.2.2\n"

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

#: includes/wasm-notavail.rst:5
msgid ""
"This module does not work or is not available on WebAssembly platforms "
"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for "
"more information."
msgstr ""
"Bu modül WebAssembly platformları olan ``wasm32-emscripten`` ve ``wasm32-"
"wasi`` üzerinde çalışmaz veya kullanılamaz. Daha fazla bilgi için :ref:`wasm-"
"availability` sayfasına bakın."
14 changes: 11 additions & 3 deletionsmerge.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,7 +85,9 @@ def update_makefile(cpython_repo: Path) -> None:
used to generate the `po` files.
"""
makefile = Path("Makefile").read_text(encoding="UTF-8")
head = run("git", "-C", cpython_repo, "rev-parse", "HEAD", stdout=PIPE).stdout.strip()
head = run(
"git", "-C", cpython_repo, "rev-parse", "HEAD", stdout=PIPE
).stdout.strip()
makefile = re.sub(
"^CPYTHON_CURRENT_COMMIT :=.*$",
f"CPYTHON_CURRENT_COMMIT := {head}",
Expand DownExpand Up@@ -121,8 +123,14 @@ def main():
cwd=args.cpython_repo / "Doc",
)
pot_path = args.cpython_repo / "pot"
upstream = {file.relative_to(pot_path).with_suffix(".po") for file in pot_path.glob("**/*.pot")}
downstream = {Path(po) for po in run("git", "ls-files", "*.po", stdout=PIPE).stdout.splitlines()}
upstream = {
file.relative_to(pot_path).with_suffix(".po")
for file in pot_path.glob("**/*.pot")
}
downstream = {
Path(po)
for po in run("git", "ls-files", "*.po", stdout=PIPE).stdout.splitlines()
}
copy_new_files(upstream - downstream, pot_path=pot_path)
update_known_files(upstream & downstream, pot_path=pot_path)
remove_old_files(downstream - upstream)
Expand Down
17 changes: 14 additions & 3 deletionsscripts/format_check.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,12 @@
import polib

parser = argparse.ArgumentParser()
parser.add_argument("subject", nargs="?", default=None, help="Subject to check (file or directory)")
parser.add_argument(
"path",
nargs="?",
default=None,
help="Path to the .po file or directory containing .po files",
)
parser.add_argument("-t", "--threshold", type=int, default=85)
args = parser.parse_args()

Expand All@@ -28,7 +33,11 @@

elif os.path.isfile(args.subject):
is_file = True
subject = args.subject if os.path.isabs(args.subject) else os.path.join(subject, args.subject)
subject = (
args.subject
if os.path.isabs(args.subject)
else os.path.join(subject, args.subject)
)

else:
print("Invalid subject, showing all files.")
Expand DownExpand Up@@ -56,7 +65,9 @@ def main(subject):
wordsid = [word for word in entry.msgid.split() if has_delimiters(word)]

if has_delimiters(entry.msgstr):
wordsstr = [word for word in entry.msgstr.split() if has_delimiters(word)]
wordsstr = [
word for word in entry.msgstr.split() if has_delimiters(word)
]

if len(wordsid) != len(wordsstr):
key = pofilename
Expand Down
100 changes: 100 additions & 0 deletionsscripts/progress.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
import os
from argparse import ArgumentParser
from functools import lru_cache
from subprocess import check_output

import polib

parser = ArgumentParser()
parser.add_argument(
"path",
nargs="?",
default=None,
help="Path to the .po file or directory containing .po files",
)
parser.add_argument(
"--no-cache", action="store_true", default=False, help="Don't use cache"
)
args = parser.parse_args()


def main():
global git_root
total_progress = False
git_root = get_git_root()

if args.no_cache:
progress.cache_clear()
get_git_root.cache_clear()

if args.path is None:
print("No path specified, showing total progress...")
args.path = os.path.abspath(git_root).replace("\\", "/")
total_progress = True

else:
args.path = os.path.abspath(args.path).replace("\\", "/")

if os.path.isfile(args.path):
paths = [args.path]

elif os.path.isdir(args.path):
paths = []
for root, _, files in os.walk(args.path):
paths.extend(
os.path.join(root, file) for file in files if file.endswith(".po")
)
paths = map(lambda x: x.replace("\\", "/"), paths)

else:
print("Invalid path")
return -1

try:
progress(tuple(paths), total_progress)
return 0
except Exception as e:
print(f"Error: {e}")
return -1


@lru_cache(maxsize=512)
def progress(paths, total_progress=False):
total = 0
translated = 0
previous = "/"
is_root = True
for path in paths:
pofile = polib.pofile(path)
total += len(pofile) - len(pofile.obsolete_entries())
translated += len(pofile.translated_entries())
path = path.replace(f"{git_root}", "")
if is_root and len(path.split("/")) == 2:
print()
print("PYTHON-DOCS-TR")
print("-" * 14)
is_root = False
if (previous.split("/")[1] != path.split("/")[1]) and len(path.split("/")) > 2:
print()
print(path.split("/")[1].upper())
print("-" * len(path.split("/")[1].upper()))
previous = path
print(f"{path}: {pofile.percent_translated()}%")

dir_path = args.path.replace(f"{git_root}", "/").replace("//", "/")
total_progress_of = "/" if total_progress else dir_path
print()
print(
f"Total progress of {total_progress_of}: {round(translated / total * 100, 2)}%"
) if len(paths) > 1 else None


@lru_cache(maxsize=1)
def get_git_root():
return os.path.abspath(
check_output(["git", "rev-parse", "--show-toplevel"]).decode("utf-8").strip()
).replace("\\", "/")


if __name__ == "__main__":
main()
20 changes: 17 additions & 3 deletionsscripts/translate.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,13 @@

parser = ArgumentParser()
parser.add_argument("filename", help="File to translate")
parser.add_argument("-t", "--translator", choices=["google", "deepl"], default="deepl", help="Translator to use")
parser.add_argument(
"-t",
"--translator",
choices=["google", "deepl"],
default="deepl",
help="Translator to use",
)
parser.add_argument(
"-a",
"--api-key",
Expand All@@ -18,7 +24,13 @@
)
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose mode")
parser.add_argument("-d", "--debug", action="store_true", help="Debug mode")
parser.add_argument("-s", "--skip-translated-entries", choices=[True, False], default=True, help="Skip already translated entries")
parser.add_argument(
"-s",
"--skip-translated-entries",
choices=[True, False],
default=True,
help="Skip already translated entries",
)

args = parser.parse_args()

Expand DownExpand Up@@ -117,7 +129,9 @@ def undo_sphinx_directives_protection(placeholders: dict, translated_text: str)
if args.translator.lower() == "google":
translator = GoogleTranslator(source="en", target="tr")
elif args.translator.lower() == "deepl":
translator = DeeplTranslator(api_key=args.api_key, source="en", target="tr", use_free_api=True)
translator = DeeplTranslator(
api_key=args.api_key, source="en", target="tr", use_free_api=True
)
else:
raise ValueError("Invalid translator")

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp