From c93e9efbfc7a07d1442dff75f42897426a2531db Mon Sep 17 00:00:00 2001 From: Eric Werner Date: Sat, 15 Apr 2023 16:54:54 +0200 Subject: [PATCH] Hotstrings 0.3.1: Fixed import script --- HotStrings/a2_menu_item_import_hotstrings.py | 14 +++++++++----- HotStrings/a2module.json | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/HotStrings/a2_menu_item_import_hotstrings.py b/HotStrings/a2_menu_item_import_hotstrings.py index f1d6a72..2738468 100644 --- a/HotStrings/a2_menu_item_import_hotstrings.py +++ b/HotStrings/a2_menu_item_import_hotstrings.py @@ -1,16 +1,20 @@ # a2 menu item script "import_hotstrings" import a2core +import a2mod from a2qt import QtWidgets -def main(a2: a2core.A2Obj, mod): - print('Import Hotstrings ... %s' % __name__) +log = a2core.get_logger(__name__) + +def main(a2: a2core.A2Obj, mod: a2mod.Mod): file_path, _ = QtWidgets.QFileDialog.getOpenFileName( None, 'Import Hotstrings Data', a2.paths.a2, '(*.ahk *.json)' ) if not file_path: return + log.info('Importing Hotstrings from ...\n %s', file_path) + import os import a2util import hotstrings_io @@ -23,7 +27,7 @@ def main(a2: a2core.A2Obj, mod): elif ext == '.json': hs_input = a2util.json_read(file_path) else: - raise NotImplementedError('Unknown file type "%s"!' % ext) + raise NotImplementedError(f'Unknown file type "{ext}"!') hotstrings_io.scopes_to_groups(hs_input) @@ -34,7 +38,7 @@ def main(a2: a2core.A2Obj, mod): for name, group in hs_input.get(Args.groups, {}).items(): if not Args.hotstrings in group: continue - if not len(group[Args.hotstrings]): + if not group[Args.hotstrings]: continue name = f'Imported {base} - {name}' name = a2util.get_next_free_number(name, current_names) @@ -42,6 +46,6 @@ def main(a2: a2core.A2Obj, mod): current_groups[name] = group current_names.append(name) - mod.set_user_cfg({'name': hotstrings_io.Args.hotstrings}, current_cfg) + mod.set_user_cfg({Args.hotstrings: current_cfg}) a2.win.load_runtime_and_ui() a2.win.check_element(Args.hotstrings) diff --git a/HotStrings/a2module.json b/HotStrings/a2module.json index 53203e5..71a9885 100644 --- a/HotStrings/a2module.json +++ b/HotStrings/a2module.json @@ -9,7 +9,7 @@ ], "typ": "nfo", "url": "https://github.com/ewerybody/a2.modules/tree/master/HotStrings#hotstrings", - "version": "0.3" + "version": "0.3.1" }, { "label": "Import Hotstrings", @@ -30,4 +30,4 @@ "name": "hotstrings", "typ": "a2_local_element" } -] +] \ No newline at end of file