From 251344c5a054da572e02e883eb664a7cc5529d32 Mon Sep 17 00:00:00 2001 From: Sander Land Date: Mon, 7 Dec 2020 13:33:08 +0100 Subject: [PATCH] fixes --- i18n.py | 24 ++++++++++-------- katrain/__main__.py | 3 ++- katrain/core/game.py | 9 ++++--- katrain/gui/popups.py | 18 +++++++------ .../i18n/locales/de/LC_MESSAGES/katrain.mo | Bin 16377 -> 16364 bytes .../i18n/locales/de/LC_MESSAGES/katrain.po | 4 +-- .../i18n/locales/en/LC_MESSAGES/katrain.mo | Bin 15652 -> 15639 bytes .../i18n/locales/en/LC_MESSAGES/katrain.po | 4 +-- .../i18n/locales/es/LC_MESSAGES/katrain.mo | Bin 15773 -> 15760 bytes .../i18n/locales/es/LC_MESSAGES/katrain.po | 4 +-- .../i18n/locales/fr/LC_MESSAGES/katrain.mo | Bin 17480 -> 17467 bytes .../i18n/locales/fr/LC_MESSAGES/katrain.po | 4 +-- .../i18n/locales/ko/LC_MESSAGES/katrain.mo | Bin 17413 -> 17400 bytes .../i18n/locales/ko/LC_MESSAGES/katrain.po | 4 +-- .../i18n/locales/ru/LC_MESSAGES/katrain.mo | Bin 22203 -> 22190 bytes .../i18n/locales/ru/LC_MESSAGES/katrain.po | 4 +-- 16 files changed, 44 insertions(+), 34 deletions(-) diff --git a/i18n.py b/i18n.py index e9be731..51288e0 100644 --- a/i18n.py +++ b/i18n.py @@ -101,14 +101,18 @@ for lang in locales: print("Fixed", pofile[lang], "and converted ->", mofile) -for file in glob.glob("**/*.py") + glob.glob("**/*.kv"): - with open(file, "r") as f: - for i, line in enumerate(f.readlines()): - matches = [m.strip() for m in re.findall(r"i18n._\((.*?)\)", line)] - for msgid in matches: - stripped_msgid = msgid.strip("\"'") - if stripped_msgid and msgid[0] in ['"', "'"] and stripped_msgid not in strings_to_langs: # not code - print(f"Missing {msgid} used in code at \t{file}:{i} \t'{line.strip()}'") - errors += 1 - +for ext in ["py", "kv"]: + lc = 0 + for file in glob.glob(f"katrain/*.{ext}") + glob.glob(f"katrain/**/*.{ext}"): + with open(file, "r") as f: + for i, line in enumerate(f.readlines()): + if line.strip(): + lc += 1 + matches = [m.strip() for m in re.findall(r"i18n._\((.*?)\)", line)] + for msgid in matches: + stripped_msgid = msgid.strip("\"'") + if stripped_msgid and msgid[0] in ['"', "'"] and stripped_msgid not in strings_to_langs: # not code + print(f"Missing {msgid} used in code at \t{file}:{i} \t'{line.strip()}'") + errors += 1 + print(f"Checked {lc} lines of {ext} code for missing i18n entries.") sys.exit(int(errors)) diff --git a/katrain/__main__.py b/katrain/__main__.py index 80608a3..21161ff 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -64,7 +64,8 @@ from katrain.core.constants import ( STATUS_ERROR, STATUS_INFO, PLAYING_NORMAL, - PLAYER_HUMAN, SGF_INTERNAL_COMMENTS_MARKER, + PLAYER_HUMAN, + SGF_INTERNAL_COMMENTS_MARKER, ) from katrain.gui.popups import ConfigTeacherPopup, ConfigTimerPopup, I18NPopup, SaveSGFPopup from katrain.core.base_katrain import KaTrainBase diff --git a/katrain/core/game.py b/katrain/core/game.py index f995d12..0021351 100644 --- a/katrain/core/game.py +++ b/katrain/core/game.py @@ -20,7 +20,8 @@ from katrain.core.constants import ( STATUS_ERROR, STATUS_INFO, STATUS_TEACHING, - VERSION, SGF_INTERNAL_COMMENTS_MARKER, + VERSION, + SGF_INTERNAL_COMMENTS_MARKER, ) from katrain.core.engine import KataGoEngine from katrain.core.game_node import GameNode @@ -407,7 +408,9 @@ class Game: x_properties["RE"] = self.end_result x_properties["KTV"] = ANALYSIS_FORMAT_VERSION self.root.properties = {**root_properties, **{k: [v] for k, v in x_properties.items()}} - player_names = {bw: re.sub(r"[\u200b\u3164'<>:\"/\\|?*]", "", self.root.get_property("P" + bw, bw)) for bw in "BW"} + player_names = { + bw: re.sub(r"[\u200b\u3164'<>:\"/\\|?*]", "", self.root.get_property("P" + bw, bw)) for bw in "BW" + } base_game_name = f"{PROGRAM_NAME}_{player_names['B']} vs {player_names['W']}" return f"{base_game_name} {self.game_id}.sgf" @@ -536,7 +539,7 @@ class Game: nonlocal count, cn cand = node.candidate_moves if self.katrain.game is not self: - return # a new game happened + return # a new game happened if cand: move = Move.from_gtp(cand[0]["move"], player=node.next_player) else: diff --git a/katrain/gui/popups.py b/katrain/gui/popups.py index 27d8a8e..ccbf738 100644 --- a/katrain/gui/popups.py +++ b/katrain/gui/popups.py @@ -253,18 +253,17 @@ class NewGamePopup(QuickConfigGui): def normalized_rules(self): rules = self.katrain.game.root.get_property("RU", "japanese").strip().lower() for abbr, name in self.katrain.engine.RULESETS_ABBR: - if abbr==rules or abbr==rules: + if abbr == rules or abbr == rules: return name - - def update_playerinfo(self,*args): + def update_playerinfo(self, *args): for bw, player_setup in self.player_setup.players.items(): name = self.player_name[bw].text if name: self.katrain.game.root.set_property("P" + bw, name) self.katrain.update_player(bw, **player_setup.player_type_dump) - def update_from_current_game(self): + def update_from_current_game(self, *args): for bw in "BW": name = self.katrain.game.root.get_property("P" + bw, None) if name: @@ -274,7 +273,6 @@ class NewGamePopup(QuickConfigGui): if rules is not None: self.rules_spinner.select_key(rules.strip()) - def update_config(self, save_to_file=True): super().update_config(save_to_file=save_to_file) self.katrain.log(f"New game settings: {self.katrain.config('game')}", OUTPUT_DEBUG) @@ -288,11 +286,15 @@ class NewGamePopup(QuickConfigGui): props = self.collect_properties(self) root = self.katrain.game.root changed = False - for k, currentval, newval in [("RU",self.normalized_rules(), props["game/rules"]), ("KM", root.komi, props["game/komi"])]: - if currentval !=newval: + for k, currentval, newval in [ + ("RU", self.normalized_rules(), props["game/rules"]), + ("KM", root.komi, props["game/komi"]), + ]: + if currentval != newval: changed = True self.katrain.log( - f"Property {k} changed from {currentval} to {newval}, triggering re-analysis of entire game.", OUTPUT_INFO + f"Property {k} changed from {currentval} to {newval}, triggering re-analysis of entire game.", + OUTPUT_INFO, ) self.katrain.game.root.set_property(k, newval) self.update_playerinfo() diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo index 6118c3947016741a938db41f598dd75bbaff33e7..4e7a84e65615a1a03c28235aee60f903921fde59 100644 GIT binary patch delta 401 zcmXZYJxhX77{>8Se9B%lO>HPq(p-{E0uxGmqHt-@!H*G6y0x6KA#gXET7ss?EvIN` zi}Z8YR)d4k|1PKBIro97!H!y^MLe8Clb!vKEF{lo+AWAxBFkwUnPR=AE~ zOye3B(DIJZ^3E}j4csNTGoRo2PD=3b;7c1g#1xLuHvB@{c!oiYok|OsMEj8~w4yB9 iVg<}#2`#6IJ9vrK)58nAN1e6X+k@9gr8w}aKi)4}buHci delta 411 zcmXZYze_?<7{>8OvNH3U76}oF{eV*RLJ$dhGmHqLp*@EPY`a5SG@Um8frg;HXi73@ zcB-+#EvkQ@t;r_8Z#jL=c@I3#%lUSF*WOLIhNQ=eG>6IRziSxdzJnWhfMa-xDQuyK z*I2?^EMgBQF%n2VdborETFx;};}uTfT_E>&cxGUQFBr!+jNtpw4_xQ|g;7jzN#mG7 zE6id73z)<*THYR7-XX5w5#|YY!})#9Ni#e=)udT`#d-Wh+wd1{o*Uf92UI-_bDgfYS(<3(&cc(6)283~sq~`*i|aCP diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po index b956b6f..9a5ce8f 100644 --- a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po @@ -817,5 +817,5 @@ msgstr "Fast playout to game end" #. TODO - Status message msgid "playtoend:status" msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moved " -"played.moves played." +"Playing the game quickly to the end, please wait ... {num_moves} moves " +"played." diff --git a/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo index 2c3ffbf7f7e46ee4f489c02d98732212031b1289..f5d33c2bf7c098a3ec62ec43c3ba84dd3e36ac8a 100644 GIT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(p8M5cjyJSPTY>7=#&wCs>zG+>#%_;4CIV zl%a?#Y7&g%7w{Xb*arS@IO%s^=iKMD-*KNE_mE8ZV@Yqj(i|?-r7~{f7#`pn9);|2 zp4`R=Z*T?gaTR}X3WvCe#aLRxb=<;3EMXfncooZQl%mUkd5ZA679yB}Ob!|Yw z3}Xjx@D)q=fic|U9r}tQS!`e)pHcUWF@W=;*#CzGjZ+#+)Q8vT#&6>u+tk0PL7Hq+ zAB|6_4_c`AUrgJ8zfgFJ%NW)~;_f)+t& zX>t+V9o)n}K~iX|@5wtnKJRx9_uRw%>4&=Sq48}rco30cN#q#6F@@o4K1^c)U6X65 z{W`|5g;&_a3QjSBR$1f@Q|RI&=J6Hvo=-f&d0B%0p9O^^g%#@H4O;kXw3uEaAD}Mg z8J~?!)PZf(^KT{(OdjDm^$*l!$Bb)1mTjtGQrg$h~Cx|h!3J6XbKz+3TML* zB5-n72%@P!KoEiu-1}aA%l+JQIOp7R`yK1GV|9-r-if3UM+!HKQW_6&1+TGyw|+dt z4dNe+;taF6RFcjyhe>?I8or^KyY5IC%wh~(+(OThH@`fQNRa5`8h&8_$G#K1BL2lN zR!^lk*3c|^gQox9_Zdyy2by^U%;Pt*noV0H5`e@D{ux-^UPB`J$VOyCKw zVKa>TI7R${ag3Cu9FF4_7BG#MxQBOW=FT|MGUhRfHJrwVBme)=CXpiXgcJCN5&R7O z!UN)O9L4H}G>M037ClANe;yj3se42-?*&)!9d9g_+#DS8;QE7&UtMX1f*)MMEa!}2 z6_a?3^yv(Tu#UsnLi5oD#_$>!u!D2hM;m|9%(1tbi7v|ayiD&t?%2^v=E&Qv?N=6i IiPF``A7Fq!lK=n! diff --git a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po index 9955655..c081e63 100644 --- a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po @@ -814,5 +814,5 @@ msgstr "Fast playout to game end" #. TODO - Status message msgid "playtoend:status" msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moved " -"played.moves played." +"Playing the game quickly to the end, please wait ... {num_moves} moves " +"played."