diff --git a/katrain/__main__.py b/katrain/__main__.py index 2f69660..29b05fd 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -6,7 +6,7 @@ os.environ["KCFG_KIVY_LOG_LEVEL"] = os.environ.get("KCFG_KIVY_LOG_LEVEL", "warni os.environ["KIVY_AUDIO"] = "sdl2" # force working audio # next, icon -from katrain.core.utils import find_package_resource +from katrain.core.utils import find_package_resource, PATHS from kivy.config import Config from kivy.utils import platform @@ -471,7 +471,8 @@ class KaTrainApp(MDApp): kv_file = find_package_resource("katrain/gui.kv") popup_kv_file = find_package_resource("katrain/popups.kv") - resource_add_path(os.path.split(kv_file)[0]) + resource_add_path(PATHS["PACKAGE"]) + Builder.load_file(kv_file) Window.bind(on_request_close=self.on_request_close) @@ -489,9 +490,9 @@ class KaTrainApp(MDApp): self.gui.controls.set_status("") def webbrowser(self, site_key): - WEBSITES = {"homepage": HOMEPAGE + "#manual", "support": HOMEPAGE + "#support"} - if site_key in WEBSITES: - webbrowser.open(WEBSITES[site_key]) + websites = {"homepage": HOMEPAGE + "#manual", "support": HOMEPAGE + "#support"} + if site_key in websites: + webbrowser.open(websites[site_key]) def on_start(self): self.language = self.gui.config("general/lang") diff --git a/katrain/core/constants.py b/katrain/core/constants.py index ef1afc6..7eaf22e 100644 --- a/katrain/core/constants.py +++ b/katrain/core/constants.py @@ -1,4 +1,4 @@ -VERSION = "1.2.0" +VERSION = "1.2.1" HOMEPAGE = "https://github.com/sanderland/katrain" CONFIG_MIN_VERSION = "1.2.0" diff --git a/katrain/core/lang.py b/katrain/core/lang.py index 924bf23..0e286ce 100644 --- a/katrain/core/lang.py +++ b/katrain/core/lang.py @@ -56,7 +56,7 @@ class Lang(Observable): self.font_name = self.FONTS.get(lang) or DEFAULT_FONT i18n_dir, _ = os.path.split(find_package_resource("katrain/i18n/__init__.py")) locale_dir = os.path.join(i18n_dir, "locales") - locales = gettext.translation("katrain", locale_dir, languages=[lang,DEFAULT_LANGUAGE]) + locales = gettext.translation("katrain", locale_dir, languages=[lang, DEFAULT_LANGUAGE]) self.ugettext = locales.gettext # update all the kv rules attached to this text diff --git a/katrain/core/utils.py b/katrain/core/utils.py index b71c609..a9053e1 100644 --- a/katrain/core/utils.py +++ b/katrain/core/utils.py @@ -37,19 +37,19 @@ def check_thread(tb=False): # for checking if draws occur in correct thread traceback.print_stack() -PACKAGE_PATH = None +PATHS = {} def find_package_resource(path, silent_errors=False): - global PACKAGE_PATH + global PATHS if path.startswith("katrain"): - if PACKAGE_PATH is None: + if not PATHS.get("PACKAGE"): try: with pkg_resources.path("katrain", "__init__.py") as p: - PACKAGE_PATH = os.path.split(str(p))[0] + PATHS["PACKAGE"] = os.path.split(str(p))[0] except (ModuleNotFoundError, FileNotFoundError, ValueError) as e: print(f"Package file {path} not found, installation possibly broken", file=sys.stderr) return f"FILENOTFOUND/{path}" - return os.path.join(PACKAGE_PATH, path.replace("katrain\\", "katrain/").replace("katrain/", "")) + return os.path.join(PATHS["PACKAGE"], path.replace("katrain\\", "katrain/").replace("katrain/", "")) else: return os.path.abspath(os.path.expanduser(path)) # absolute path diff --git a/katrain/gui/badukpan.py b/katrain/gui/badukpan.py index 9095c01..9bc0dd9 100644 --- a/katrain/gui/badukpan.py +++ b/katrain/gui/badukpan.py @@ -112,7 +112,7 @@ class BadukPanWidget(Widget): katrain.log(f"\nAnalysis:\n{nodes_here[-1].analysis}", OUTPUT_DEBUG) katrain.log(f"\nParent Analysis:\n{nodes_here[-1].parent.analysis}", OUTPUT_DEBUG) katrain.controls.info.text = nodes_here[-1].comment(sgf=True) - katrain.controls.active_comment_node = nodes_here[-1].parent + katrain.controls.active_comment_node = nodes_here[-1] if nodes_here[-1].parent.analysis_ready: self.set_animating_pv(nodes_here[-1].parent.candidate_moves[0]["pv"], nodes_here[-1].parent) diff --git a/katrain/gui/controlspanel.py b/katrain/gui/controlspanel.py index 182e197..25e25cd 100644 --- a/katrain/gui/controlspanel.py +++ b/katrain/gui/controlspanel.py @@ -53,7 +53,9 @@ class PlayAnalyzeSelect(MDFloatLayout): def switch_ui_mode(self): # on tab press, fake ui click and trigger everything top down if self.mode == MODE_PLAY: - Clock.schedule_once(lambda _dt: self.analyze.trigger_action(duration=0)) # normal trigger does not cross thread + Clock.schedule_once( + lambda _dt: self.analyze.trigger_action(duration=0) + ) # normal trigger does not cross thread else: Clock.schedule_once(lambda _dt: self.play.trigger_action(duration=0)) diff --git a/katrain/gui/widgets/graph.py b/katrain/gui/widgets/graph.py index 7ffe718..a16b12e 100644 --- a/katrain/gui/widgets/graph.py +++ b/katrain/gui/widgets/graph.py @@ -131,14 +131,16 @@ class ScoreGraph(BackgroundMixin): self.nodes[index] = node if index > 1 and node.parent: # sometimes things go so fast backfill, bfnode = index - 1, node.parent - while self.nodes[backfill] is None: + while bfnode is not None and self.nodes[backfill] != bfnode: self.nodes[backfill] = bfnode backfill -= 1 bfnode = bfnode.parent - if index + 1 < len(self.nodes) and (node is None or self.nodes[index + 1] not in node.children): + if index + 1 < len(self.nodes) and ( + node is None or not node.children or self.nodes[index + 1] != node.ordered_children[0] + ): self.nodes = self.nodes[: index + 1] # on branch switching, don't show history from other branch - if index == len(self.nodes) - 1: # possibly just switched branch + if index == len(self.nodes) - 1: # possibly just switched branch or the line above triggered while node.children: # add children back node = node.ordered_children[0] self.nodes.append(node) diff --git a/spec/KaTrain.spec b/spec/KaTrain.spec index db33f76..eca4f34 100644 --- a/spec/KaTrain.spec +++ b/spec/KaTrain.spec @@ -43,7 +43,7 @@ a.datas = [ print("DATA FILTERED", len(a.datas)) -console_names = {True:"KaTrain",False:"KaTrainNC"} +console_names = {True:"DebugKaTrain",False:"KaTrain"} for console, name in console_names.items():