Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-29 16:07:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-29 16:07:06 +0400
commit2553cdf195a1d1bbf19bde23b8bbe58de802d1f3 (patch)
treef5f7e25465de4f99c406dbba25864b150c84b67d /release/scripts/modules/bl_i18n_utils
parentab38e1d3795f58b5b3e9ca0377c9348ed710471a (diff)
style cleanup
Diffstat (limited to 'release/scripts/modules/bl_i18n_utils')
-rw-r--r--release/scripts/modules/bl_i18n_utils/bl_process_msg.py3
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/check_po.py25
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/clean_po.py1
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/import_po_from_branches.py7
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/merge_po.py5
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/rtl_preprocess.py3
-rw-r--r--release/scripts/modules/bl_i18n_utils/settings.py4
-rw-r--r--release/scripts/modules/bl_i18n_utils/spell_check_utils.py2
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/update_branches.py2
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/update_mo.py2
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/update_po.py4
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/update_pot.py7
-rwxr-xr-xrelease/scripts/modules/bl_i18n_utils/update_trunk.py1
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils.py26
14 files changed, 45 insertions, 47 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py
index f189e3a0d80..b884423606d 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py
@@ -270,7 +270,6 @@ def dump_messages_rna(messages, check_ctxt):
walk_keymap_hierarchy(KM_HIERARCHY, "KM_HIERARCHY")
-
def dump_messages_pytext(messages, check_ctxt):
""" dumps text inlined in the python user interface: eg.
@@ -291,7 +290,7 @@ def dump_messages_pytext(messages, check_ctxt):
# Break recursive nodes look up on some kind of nodes.
# E.g. we don’t want to get strings inside subscripts (blah["foo"])!
- stopper_nodes = {ast.Subscript,}
+ stopper_nodes = {ast.Subscript, }
for func_id, func in bpy.types.UILayout.bl_rna.functions.items():
# check it has a 'text' argument
diff --git a/release/scripts/modules/bl_i18n_utils/check_po.py b/release/scripts/modules/bl_i18n_utils/check_po.py
index b669a9ddff2..03a933887c6 100755
--- a/release/scripts/modules/bl_i18n_utils/check_po.py
+++ b/release/scripts/modules/bl_i18n_utils/check_po.py
@@ -94,7 +94,6 @@ def main():
help="Restrict processed languages to those.")
args = parser.parse_args()
-
if args.pot:
global FILE_NAME_POT
FILE_NAME_POT = args.pot
@@ -145,24 +144,24 @@ def main():
ret = t
if args.stats and glob_stats["nbr"] != 0.0:
- nbr_contexts = len(glob_stats["contexts"]-{""})
+ nbr_contexts = len(glob_stats["contexts"] - {""})
if nbr_contexts != 1:
if nbr_contexts == 0:
nbr_contexts = "No"
_ctx_txt = "s are"
else:
_ctx_txt = " is"
- print("\nAverage stats for all {:.0f} processed files:\n" \
- " {:>6.1%} done!\n" \
- " {:>6.1%} of messages are tooltips.\n" \
- " {:>6.1%} of tooltips are translated.\n" \
- " {:>6.1%} of translated messages are tooltips.\n" \
- " {:>6.1%} of messages are commented.\n" \
- " The org msgids are currently made of {} signs.\n" \
- " All processed translations are currently made of {} signs.\n" \
- " {} specific context{} present:\n {}\n" \
- "".format(glob_stats["nbr"], glob_stats["lvl"]/glob_stats["nbr"],
- glob_stats["lvl_ttips"]/glob_stats["nbr"],
+ print("\nAverage stats for all {:.0f} processed files:\n"
+ " {:>6.1%} done!\n"
+ " {:>6.1%} of messages are tooltips.\n"
+ " {:>6.1%} of tooltips are translated.\n"
+ " {:>6.1%} of translated messages are tooltips.\n"
+ " {:>6.1%} of messages are commented.\n"
+ " The org msgids are currently made of {} signs.\n"
+ " All processed translations are currently made of {} signs.\n"
+ " {} specific context{} present:\n {}\n"
+ "".format(glob_stats["nbr"], glob_stats["lvl"] / glob_stats["nbr"],
+ glob_stats["lvl_ttips"] / glob_stats["nbr"],
glob_stats["lvl_trans_ttips"]/glob_stats["nbr"],
glob_stats["lvl_ttips_in_trans"]/glob_stats["nbr"],
glob_stats["lvl_comm"]/glob_stats["nbr"], glob_stats["nbr_signs"],
diff --git a/release/scripts/modules/bl_i18n_utils/clean_po.py b/release/scripts/modules/bl_i18n_utils/clean_po.py
index f0b8dd6b1d2..2924ad9fb74 100755
--- a/release/scripts/modules/bl_i18n_utils/clean_po.py
+++ b/release/scripts/modules/bl_i18n_utils/clean_po.py
@@ -65,7 +65,6 @@ def main():
help="Restrict processed languages to those.")
args = parser.parse_args()
-
ret = 0
if args.langs:
diff --git a/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py b/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py
index cbbef17b37d..a15bea9ef0d 100755
--- a/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py
+++ b/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py
@@ -56,12 +56,11 @@ def main():
help="Restrict processed languages to those.")
args = parser.parse_args()
-
ret = 0
- threshold = float(settings.IMPORT_MIN_LEVEL)/100.0
+ threshold = float(settings.IMPORT_MIN_LEVEL) / 100.0
if args.threshold is not None:
- threshold = float(args.threshold)/100.0
+ threshold = float(args.threshold) / 100.0
for lang in os.listdir(BRANCHES_DIR):
if args.langs and lang not in args.langs:
@@ -74,7 +73,7 @@ def main():
trans_msgs = stats["trans_msg"]
lvl = 0.0
if tot_msgs:
- lvl = float(trans_msgs)/float(tot_msgs)
+ lvl = float(trans_msgs) / float(tot_msgs)
if lvl > threshold:
if state["is_broken"] and args.strict:
print("{:<10}: {:>6.1%} done, but BROKEN, skipped." \
diff --git a/release/scripts/modules/bl_i18n_utils/merge_po.py b/release/scripts/modules/bl_i18n_utils/merge_po.py
index 51e587ca4c8..baf67de2e81 100755
--- a/release/scripts/modules/bl_i18n_utils/merge_po.py
+++ b/release/scripts/modules/bl_i18n_utils/merge_po.py
@@ -21,7 +21,7 @@
# <pep8 compliant>
# Merge one or more .po files into the first dest one.
-# If a msgkey is present in more than one merged po, the one in the first file wins, unless
+# If a msgkey is present in more than one merged po, the one in the first file wins, unless
# it’s marked as fuzzy and one later is not.
# The fuzzy flag is removed if necessary.
# All other comments are never modified.
@@ -59,7 +59,6 @@ def main():
help="The po's to merge into the dst.po one.")
args = parser.parse_args()
-
ret = 0
done_msgkeys = set()
done_fuzzy_msgkeys = set()
@@ -78,7 +77,7 @@ def main():
# If we don’t want to replace existing valid translations, pre-populate
# done_msgkeys and done_fuzzy_msgkeys.
if not args.replace:
- done_msgkeys = dst_states["trans_msg"].copy()
+ done_msgkeys = dst_states["trans_msg"].copy()
done_fuzzy_msgkeys = dst_states["fuzzy_msg"].copy()
for po in args.src:
messages, states, stats = utils.parse_messages(po)
diff --git a/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py b/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py
index 9b2ee983952..5ee5c71be8b 100755
--- a/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py
+++ b/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py
@@ -86,6 +86,7 @@ FRIBIDI_FLAGS_DEFAULT = FRIBIDI_FLAG_SHAPE_MIRRORING | \
FRIBIDI_FLAGS_ARABIC = FRIBIDI_FLAG_SHAPE_ARAB_PRES | \
FRIBIDI_FLAG_SHAPE_ARAB_LIGA
+
##### Kernel processing funcs. #####
def protect_format_seq(msg):
"""
@@ -185,6 +186,7 @@ def log2vis(msgs):
yield fbc_str.value
+
##### Command line stuff. #####
def main():
import argparse
@@ -208,7 +210,6 @@ def main():
help="The po's to pre-process messages.")
args = parser.parse_args()
-
msgs, state, u1 = utils.parse_messages(args.src)
if state["is_broken"]:
print("Source po is BROKEN, aborting.")
diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py
index 094d8e481e9..d323dd37979 100644
--- a/release/scripts/modules/bl_i18n_utils/settings.py
+++ b/release/scripts/modules/bl_i18n_utils/settings.py
@@ -55,7 +55,7 @@ DOMAIN = "blender"
# Our own "gettext" stuff.
# File type (ext) to parse.
-PYGETTEXT_ALLOWED_EXTS = {".c", ".cpp", ".cxx", ".hpp", ".hxx", ".h"}
+PYGETTEXT_ALLOWED_EXTS = {".c", ".cpp", ".cxx", ".hpp", ".hxx", ".h"}
# Where to search contexts definitions, relative to SOURCE_DIR (defined below).
PYGETTEXT_CONTEXTS_DEFSRC = os.path.join("source", "blender", "blenfont",
@@ -97,7 +97,7 @@ _msg_re = r"(?P<msg_raw>" + _str_whole_re.format(_="_msg") + r")"
PYGETTEXT_KEYWORDS = (() +
tuple((r"{}\(\s*" + _msg_re + r"\s*\)").format(it)
for it in ("IFACE_", "TIP_", "N_")) +
- tuple((r"{}\(\s*" + _ctxt_re + r"\s*,\s*"+ _msg_re + r"\s*\)").format(it)
+ tuple((r"{}\(\s*" + _ctxt_re + r"\s*,\s*" + _msg_re + r"\s*\)").format(it)
for it in ("CTX_IFACE_", "CTX_TIP_", "CTX_N_"))
)
diff --git a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
index 12db7317011..d668f2badfc 100644
--- a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
+++ b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py
@@ -414,7 +414,7 @@ dict_uimsgs = {
"gpu", "gpus",
"hc",
"hdr",
- "hh", "mm", "ss", "ff", # hh:mm:ss:ff timecode
+ "hh", "mm", "ss", "ff", # hh:mm:ss:ff timecode
"hsv", "hsva",
"id",
"itu",
diff --git a/release/scripts/modules/bl_i18n_utils/update_branches.py b/release/scripts/modules/bl_i18n_utils/update_branches.py
index 6626fa937a6..199b09aa13a 100755
--- a/release/scripts/modules/bl_i18n_utils/update_branches.py
+++ b/release/scripts/modules/bl_i18n_utils/update_branches.py
@@ -38,6 +38,7 @@ except:
PY3 = settings.PYTHON3_EXEC
+
def main():
import argparse
parser = argparse.ArgumentParser(description="" \
@@ -59,7 +60,6 @@ def main():
help="Restrict processed languages to those.")
args = parser.parse_args()
-
ret = 0
# Generate a temp messages file.
diff --git a/release/scripts/modules/bl_i18n_utils/update_mo.py b/release/scripts/modules/bl_i18n_utils/update_mo.py
index 2ca24a76cfe..4a68f19fab0 100755
--- a/release/scripts/modules/bl_i18n_utils/update_mo.py
+++ b/release/scripts/modules/bl_i18n_utils/update_mo.py
@@ -47,7 +47,7 @@ def process_po(po, lang, mo=None):
mo_dir = os.path.join(TRUNK_MO_DIR, lang, "LC_MESSAGES")
# Create dirs if not existing!
if not os.path.isdir(mo_dir):
- os.makedirs(mo_dir, exist_ok = True)
+ os.makedirs(mo_dir, exist_ok=True)
# show stats
cmd = (GETTEXT_MSGFMT_EXECUTABLE,
diff --git a/release/scripts/modules/bl_i18n_utils/update_po.py b/release/scripts/modules/bl_i18n_utils/update_po.py
index d098b50e907..4c6495c5cfe 100755
--- a/release/scripts/modules/bl_i18n_utils/update_po.py
+++ b/release/scripts/modules/bl_i18n_utils/update_po.py
@@ -36,8 +36,8 @@ except:
GETTEXT_MSGMERGE_EXECUTABLE = settings.GETTEXT_MSGMERGE_EXECUTABLE
-BRANCHES_DIR = settings.BRANCHES_DIR
-TRUNK_PO_DIR = settings.TRUNK_PO_DIR
+BRANCHES_DIR = settings.BRANCHES_DIR
+TRUNK_PO_DIR = settings.TRUNK_PO_DIR
FILE_NAME_POT = settings.FILE_NAME_POT
diff --git a/release/scripts/modules/bl_i18n_utils/update_pot.py b/release/scripts/modules/bl_i18n_utils/update_pot.py
index ca5d156be9b..f98fc5d7705 100755
--- a/release/scripts/modules/bl_i18n_utils/update_pot.py
+++ b/release/scripts/modules/bl_i18n_utils/update_pot.py
@@ -74,12 +74,13 @@ pygettexts = tuple(re.compile(r).search
_clean_str = re.compile(settings.str_clean_re).finditer
clean_str = lambda s: "".join(m.group("clean") for m in _clean_str(s))
+
def check_file(path, rel_path, messages):
with open(path, encoding="utf-8") as f:
f = f.read()
for srch in pygettexts:
m = srch(f)
- line = pos =0
+ line = pos = 0
while m:
d = m.groupdict()
# Context.
@@ -149,6 +150,8 @@ from spell_check_utils import (dict_uimsgs,
)
_spell_checked = set()
+
+
def spell_check(txt, cache):
ret = []
@@ -194,6 +197,8 @@ def gen_empty_pot():
escape_re = tuple(re.compile(r[0]) for r in settings.ESCAPE_RE)
escape = lambda s, n: escape_re[n].sub(settings.ESCAPE_RE[n][1], s)
+
+
def merge_messages(msgs, states, messages, do_checks, spell_cache):
num_added = num_present = 0
for (context, msgid), srcs in messages.items():
diff --git a/release/scripts/modules/bl_i18n_utils/update_trunk.py b/release/scripts/modules/bl_i18n_utils/update_trunk.py
index 5e0ceab387c..b7f8f375744 100755
--- a/release/scripts/modules/bl_i18n_utils/update_trunk.py
+++ b/release/scripts/modules/bl_i18n_utils/update_trunk.py
@@ -65,7 +65,6 @@ def main():
help="Restrict processed languages to those.")
args = parser.parse_args()
-
ret = 0
failed = set()
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py
index ebf0f994a7a..3e5394d85a4 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -40,6 +40,7 @@ def stripeol(s):
def is_tooltip(msgid):
return len(msgid) > 30
+
def parse_messages(fname):
"""
Returns a tupple (messages, states, stats).
@@ -82,7 +83,6 @@ def parse_messages(fname):
fuzzy_messages = set()
commented_messages = set()
-
def clean_vars():
nonlocal reading_msgid, reading_msgstr, reading_msgctxt, \
reading_comment, is_fuzzy, is_translated, is_commented, \
@@ -143,7 +143,6 @@ def parse_messages(fname):
clean_vars()
-
with open(fname, 'r', encoding="utf-8") as f:
for line_nr, line in enumerate(f):
line = stripeol(line)
@@ -156,7 +155,7 @@ def parse_messages(fname):
reading_ctxt = True
if line.startswith(COMMENT_PREFIX):
is_commented = True
- line = line[9+len(COMMENT_PREFIX):-1]
+ line = line[9 + len(COMMENT_PREFIX):-1]
else:
line = line[9:-1]
msgctxt_lines.append(line)
@@ -167,7 +166,7 @@ def parse_messages(fname):
reading_msgid = True
if line.startswith(COMMENT_PREFIX):
is_commented = True
- line = line[7+len(COMMENT_PREFIX):-1]
+ line = line[7 + len(COMMENT_PREFIX):-1]
else:
line = line[7:-1]
msgid_lines.append(line)
@@ -180,7 +179,7 @@ def parse_messages(fname):
reading_msgid = False
reading_msgstr = True
if line.startswith(COMMENT_PREFIX):
- line = line[8+len(COMMENT_PREFIX):-1]
+ line = line[8 + len(COMMENT_PREFIX):-1]
if not is_commented:
is_broken = True
else:
@@ -194,13 +193,13 @@ def parse_messages(fname):
elif line.startswith("#"):
if reading_msgid:
if is_commented:
- msgid_lines.append(line[1+len(COMMENT_PREFIX):-1])
+ msgid_lines.append(line[1 + len(COMMENT_PREFIX):-1])
else:
msgid_lines.append(line)
is_broken = True
elif reading_msgstr:
if is_commented:
- msgstr_lines.append(line[1+len(COMMENT_PREFIX):-1])
+ msgstr_lines.append(line[1 + len(COMMENT_PREFIX):-1])
else:
msgstr_lines.append(line)
is_broken = True
@@ -338,13 +337,13 @@ def print_stats(stats, glob_stats=None, prefix=""):
lvl = lvl_ttips = lvl_trans_ttips = lvl_ttips_in_trans = lvl_comm = 0.0
if tot_msgs > 0:
- lvl = float(trans_msgs)/float(tot_msgs)
- lvl_ttips = float(tot_ttips)/float(tot_msgs)
- lvl_comm = float(comm_msgs)/float(tot_msgs+comm_msgs)
+ lvl = float(trans_msgs) / float(tot_msgs)
+ lvl_ttips = float(tot_ttips) / float(tot_msgs)
+ lvl_comm = float(comm_msgs) / float(tot_msgs+comm_msgs)
if tot_ttips > 0:
- lvl_trans_ttips = float(trans_ttips)/float(tot_ttips)
+ lvl_trans_ttips = float(trans_ttips) / float(tot_ttips)
if trans_msgs > 0:
- lvl_ttips_in_trans = float(trans_ttips)/float(trans_msgs)
+ lvl_ttips_in_trans = float(trans_ttips) / float(trans_msgs)
if glob_stats:
glob_stats["nbr"] += 1.0
@@ -368,9 +367,8 @@ def print_stats(stats, glob_stats=None, prefix=""):
"{:>6.1%} of translated messages are tooltips ({} over {}).\n"
"".format(lvl_ttips_in_trans, trans_ttips, trans_msgs),
"{:>6.1%} of messages are commented ({} over {}).\n"
- "".format(lvl_comm, comm_msgs, comm_msgs+tot_msgs),
+ "".format(lvl_comm, comm_msgs, comm_msgs + tot_msgs),
"This translation is currently made of {} signs.\n"
"".format(nbr_trans_signs))
print(prefix.join(lines))
return 0
-