From c5c0a3b010fa5bc7c7bcbd03d568c00187b3156d Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Tue, 5 Nov 2024 03:28:56 +0000 Subject: [PATCH] fix: gui resources path (#35) * fix: gui resources path * fix: allow latest ovos-gui changes companion to https://github.com/OpenVoiceOS/ovos-bus-client/pull/120 and https://github.com/OpenVoiceOS/ovos-gui/pull/53 --- {ui => gui/qt5}/Face.qml | 0 {ui => gui/qt5}/awake.qml | 0 {ui => gui/qt5}/face/Eyeball.svg | 0 {ui => gui/qt5}/face/GreySmile.svg | 0 {ui => gui/qt5}/face/Smile.svg | 0 {ui => gui/qt5}/face/lid.svg | 0 {ui => gui/qt5}/face/upper-lid.svg | 0 {ui => gui/qt5}/resting.qml | 0 requirements.txt | 2 +- scripts/bump_alpha.py | 18 ------- scripts/bump_build.py | 21 --------- scripts/bump_major.py | 27 ----------- scripts/bump_minor.py | 24 ---------- scripts/migrate_locale.py | 26 ---------- scripts/prepare_skillstore.py | 76 ------------------------------ scripts/prepare_translations.py | 53 --------------------- scripts/release_skillstore.py | 41 ---------------- scripts/remove_alpha.py | 13 ----- scripts/translate.py | 47 ------------------ setup.py | 2 +- 20 files changed, 2 insertions(+), 348 deletions(-) rename {ui => gui/qt5}/Face.qml (100%) rename {ui => gui/qt5}/awake.qml (100%) rename {ui => gui/qt5}/face/Eyeball.svg (100%) rename {ui => gui/qt5}/face/GreySmile.svg (100%) rename {ui => gui/qt5}/face/Smile.svg (100%) rename {ui => gui/qt5}/face/lid.svg (100%) rename {ui => gui/qt5}/face/upper-lid.svg (100%) rename {ui => gui/qt5}/resting.qml (100%) delete mode 100644 scripts/bump_alpha.py delete mode 100644 scripts/bump_build.py delete mode 100644 scripts/bump_major.py delete mode 100644 scripts/bump_minor.py delete mode 100644 scripts/migrate_locale.py delete mode 100644 scripts/prepare_skillstore.py delete mode 100644 scripts/prepare_translations.py delete mode 100644 scripts/release_skillstore.py delete mode 100644 scripts/remove_alpha.py delete mode 100644 scripts/translate.py diff --git a/ui/Face.qml b/gui/qt5/Face.qml similarity index 100% rename from ui/Face.qml rename to gui/qt5/Face.qml diff --git a/ui/awake.qml b/gui/qt5/awake.qml similarity index 100% rename from ui/awake.qml rename to gui/qt5/awake.qml diff --git a/ui/face/Eyeball.svg b/gui/qt5/face/Eyeball.svg similarity index 100% rename from ui/face/Eyeball.svg rename to gui/qt5/face/Eyeball.svg diff --git a/ui/face/GreySmile.svg b/gui/qt5/face/GreySmile.svg similarity index 100% rename from ui/face/GreySmile.svg rename to gui/qt5/face/GreySmile.svg diff --git a/ui/face/Smile.svg b/gui/qt5/face/Smile.svg similarity index 100% rename from ui/face/Smile.svg rename to gui/qt5/face/Smile.svg diff --git a/ui/face/lid.svg b/gui/qt5/face/lid.svg similarity index 100% rename from ui/face/lid.svg rename to gui/qt5/face/lid.svg diff --git a/ui/face/upper-lid.svg b/gui/qt5/face/upper-lid.svg similarity index 100% rename from ui/face/upper-lid.svg rename to gui/qt5/face/upper-lid.svg diff --git a/ui/resting.qml b/gui/qt5/resting.qml similarity index 100% rename from ui/resting.qml rename to gui/qt5/resting.qml diff --git a/requirements.txt b/requirements.txt index dc3694e..f88f95f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ ovos-utils>=0.0.38 ovos-workshop>=0.0.15,<3.0.0 -ovos-bus-client>=0.0.8 +ovos-bus-client>=0.0.8,<2.0.0 diff --git a/scripts/bump_alpha.py b/scripts/bump_alpha.py deleted file mode 100644 index e465543..0000000 --- a/scripts/bump_alpha.py +++ /dev/null @@ -1,18 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - else: - print(line.rstrip('\n')) diff --git a/scripts/bump_build.py b/scripts/bump_build.py deleted file mode 100644 index 61099f8..0000000 --- a/scripts/bump_build.py +++ /dev/null @@ -1,21 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_BUILD" -alpha_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - elif line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/bump_major.py b/scripts/bump_major.py deleted file mode 100644 index 2610fbb..0000000 --- a/scripts/bump_major.py +++ /dev/null @@ -1,27 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_MAJOR" -minor_var_name = "VERSION_MINOR" -build_var_name = "VERSION_BUILD" -alpha_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - elif line.startswith(minor_var_name): - print(f"{minor_var_name} = 0") - elif line.startswith(build_var_name): - print(f"{build_var_name} = 0") - elif line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/bump_minor.py b/scripts/bump_minor.py deleted file mode 100644 index 86dfd9d..0000000 --- a/scripts/bump_minor.py +++ /dev/null @@ -1,24 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") -version_var_name = "VERSION_MINOR" -build_var_name = "VERSION_BUILD" -alpha_var_name = "VERSION_ALPHA" - -with open(version_file, "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith(version_var_name): - version = int(line.split("=")[-1]) - new_version = int(version) + 1 - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(version_var_name): - print(f"{version_var_name} = {new_version}") - elif line.startswith(build_var_name): - print(f"{build_var_name} = 0") - elif line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/migrate_locale.py b/scripts/migrate_locale.py deleted file mode 100644 index 2029931..0000000 --- a/scripts/migrate_locale.py +++ /dev/null @@ -1,26 +0,0 @@ -import os -import shutil -from os.path import dirname, join, exists - -base_folder = dirname(dirname(__file__)) -res_folder = join(base_folder, "locale") -voc_folder = join(base_folder, "vocab") -dialog_folder = join(base_folder, "dialog") - -if exists(voc_folder): - for lang in os.listdir(voc_folder): - path = join(voc_folder, lang) - os.makedirs(join(res_folder, lang), exist_ok=True) - for f in os.listdir(path): - shutil.move(join(path, f), join(res_folder, lang, f)) - shutil.rmtree(path) - shutil.rmtree(voc_folder) - -if exists(dialog_folder): - for lang in os.listdir(dialog_folder): - path = join(dialog_folder, lang) - os.makedirs(join(res_folder, lang), exist_ok=True) - for f in os.listdir(path): - shutil.move(join(path, f), join(res_folder, lang, f)) - shutil.rmtree(path) - shutil.rmtree(dialog_folder) diff --git a/scripts/prepare_skillstore.py b/scripts/prepare_skillstore.py deleted file mode 100644 index bef7299..0000000 --- a/scripts/prepare_skillstore.py +++ /dev/null @@ -1,76 +0,0 @@ -from ovos_skills_manager import SkillEntry -from os.path import exists, join, dirname -from shutil import rmtree -import os -from os import makedirs -import json -from ovos_utils.bracket_expansion import expand_parentheses, expand_options - - -branch = "dev" -repo = "skill-ovos-naptime" -author = "OpenVoiceOS" - -url = f"https://github.com/{author}/{repo}@{branch}" - -skill = SkillEntry.from_github_url(url) -tmp_skills = "/tmp/osm_installed_skills" -skill_folder = f"{tmp_skills}/{skill.uuid}" - -base_dir = dirname(dirname(__file__)) -desktop_dir = join(base_dir, "res", "desktop") -android_ui = join(base_dir, "ui", "+android") -makedirs(desktop_dir, exist_ok=True) - -readme = join(base_dir, "README.md") -jsonf = join(desktop_dir, "skill.json") -desktopf = join(desktop_dir, f"{repo}.desktop") -skill_code = join(base_dir, "__init__.py") - -res_folder = join(base_dir, "locale", "en-us") - - -def read_samples(path): - samples = [] - with open(path) as fi: - for _ in fi.read().split("\n"): - if _ and not _.strip().startswith("#"): - samples += expand_options(_) - return samples - -samples = [] -for root, folders, files in os.walk(res_folder): - for f in files: - if f.endswith(".intent"): - samples += read_samples(join(root, f)) -skill._data["examples"] = list(set(samples)) - -has_android = exists(android_ui) -with open(skill_code) as f: - has_homescreen = f"{repo}.{author}.home" in f.read() - -if not exists(readme): - with open(readme, "w") as f: - f.write(skill.generate_readme()) - -if has_homescreen and not exists(desktopf): - with open(desktopf, "w") as f: - f.write(skill.desktop_file) - -if not exists(jsonf): - data = skill.json - with open(jsonf, "w") as f: - if not has_android or not has_homescreen: - data.pop("android") - if not has_homescreen: - data.pop("desktop") - data["desktopFile"] = False -else: - with open(jsonf) as f: - data = json.load(f) - -# set dev branch -data["branch"] = "dev" - -with open(jsonf, "w") as f: - json.dump(data, f, indent=4) diff --git a/scripts/prepare_translations.py b/scripts/prepare_translations.py deleted file mode 100644 index 01a674d..0000000 --- a/scripts/prepare_translations.py +++ /dev/null @@ -1,53 +0,0 @@ -"""this script should run every time the contents of the locale folder change -except if PR originated from @gitlocalize-app -TODO - on commit to dev -""" - -import json -from os.path import dirname -import os - -locale = f"{dirname(dirname(__file__))}/locale" -tx = f"{dirname(dirname(__file__))}/translations" - - -for lang in os.listdir(locale): - intents = {} - dialogs = {} - vocs = {} - regexes = {} - for root, _, files in os.walk(f"{locale}/{lang}"): - b = root.split(f"/{lang}")[-1] - - for f in files: - if b: - fid = f"{b}/{f}" - else: - fid = f - with open(f"{root}/{f}") as fi: - strings = [l.replace("{{", "{").replace("}}", "}") - for l in fi.read().split("\n") if l.strip() - and not l.startswith("#")] - - if fid.endswith(".intent"): - intents[fid] = strings - elif fid.endswith(".dialog"): - dialogs[fid] = strings - elif fid.endswith(".voc"): - vocs[fid] = strings - elif fid.endswith(".rx"): - regexes[fid] = strings - - os.makedirs(f"{tx}/{lang.lower()}", exist_ok=True) - if intents: - with open(f"{tx}/{lang.lower()}/intents.json", "w") as f: - json.dump(intents, f, indent=4) - if dialogs: - with open(f"{tx}/{lang.lower()}/dialogs.json", "w") as f: - json.dump(dialogs, f, indent=4) - if vocs: - with open(f"{tx}/{lang.lower()}/vocabs.json", "w") as f: - json.dump(vocs, f, indent=4) - if regexes: - with open(f"{tx}/{lang.lower()}/regexes.json", "w") as f: - json.dump(regexes, f, indent=4) diff --git a/scripts/release_skillstore.py b/scripts/release_skillstore.py deleted file mode 100644 index a176d89..0000000 --- a/scripts/release_skillstore.py +++ /dev/null @@ -1,41 +0,0 @@ -import json -from os.path import join, dirname - -base_dir = dirname(dirname(__file__)) - - -def get_version(): - """ Find the version of the package""" - version_file = join(base_dir, 'version.py') - major, minor, build, alpha = (None, None, None, None) - with open(version_file) as f: - for line in f: - if 'VERSION_MAJOR' in line: - major = line.split('=')[1].strip() - elif 'VERSION_MINOR' in line: - minor = line.split('=')[1].strip() - elif 'VERSION_BUILD' in line: - build = line.split('=')[1].strip() - elif 'VERSION_ALPHA' in line: - alpha = line.split('=')[1].strip() - - if ((major and minor and build and alpha) or - '# END_VERSION_BLOCK' in line): - break - version = f"{major}.{minor}.{build}" - if alpha and int(alpha) > 0: - version += f"a{alpha}" - return version - - -desktop_dir = join(base_dir, "res", "desktop") - -jsonf = join(desktop_dir, "skill.json") - -with open(jsonf) as f: - data = json.load(f) - -data["branch"] = "v" + get_version() - -with open(jsonf, "w") as f: - json.dump(data, f, indent=4) diff --git a/scripts/remove_alpha.py b/scripts/remove_alpha.py deleted file mode 100644 index fca7342..0000000 --- a/scripts/remove_alpha.py +++ /dev/null @@ -1,13 +0,0 @@ -import fileinput -from os.path import join, dirname - - -version_file = join(dirname(dirname(__file__)), "version.py") - -alpha_var_name = "VERSION_ALPHA" - -for line in fileinput.input(version_file, inplace=True): - if line.startswith(alpha_var_name): - print(f"{alpha_var_name} = 0") - else: - print(line.rstrip('\n')) diff --git a/scripts/translate.py b/scripts/translate.py deleted file mode 100644 index 8942491..0000000 --- a/scripts/translate.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -from os.path import dirname, join, exists -from ovos_utils.bracket_expansion import expand_options -from googletranslate_neon_plugin import GoogleTranslator - -tx = GoogleTranslator() - -src_lang = "en-us" -target_langs = ["es-es", "de-de", "fr-fr", "it-it", "pt-pt"] - -exts = [".voc", ".dialog", ".intent", ".entity"] -res_folder = join(dirname(dirname(__file__)), "locale") -target_langs = list(set(target_langs + os.listdir(res_folder))) - -src_files = {} -for root, dirs, files in os.walk(res_folder): - if src_lang not in root: - continue - for f in files: - if any(f.endswith(e) for e in exts): - src_files[f] = join(root, f) - -for lang in target_langs: - os.makedirs(join(res_folder, lang), exist_ok=True) - - for name, src in src_files.items(): - dst = join(res_folder, lang, name) - if exists(dst): - continue - - tx_lines = [] - with open(src) as f: - lines = [l for l in f.read().split("\n") if l and not l.startswith("#")] - - for l in lines: - expanded = expand_options(l) - for l2 in expanded: - try: - translated = tx.translate(l2, target=lang, source=src_lang) - tx_lines.append(translated) - except: - continue - - with open(dst, "w") as f: - f.write(f"# auto translated from {src_lang} to {lang}\n") - for translated in set(tx_lines): - f.write(translated + "\n") diff --git a/setup.py b/setup.py index 2777f4d..7a43f10 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def get_requirements(requirements_filename: str): def find_resource_files(): - resource_base_dirs = ("locale", "ui", "vocab", "dialog", "regex", "skill") + resource_base_dirs = ("locale", "gui", "vocab", "dialog", "regex", "skill") base_dir = path.dirname(__file__) package_data = ["*.json"] for res in resource_base_dirs: