From 3e297095ed63fd560716a1afd4e290ccd45ecf66 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:45:23 +0000 Subject: [PATCH] Add HD Satelit and OpenSPA catalogs - images.json: HD Satelit (monea-software/hdsatelit-enigma2, main, enigma2/ subfolder) and OpenSPA (OpenSPA/dvbapp2, master). - build_catalogs.py: optional "path" for repositories that keep enigma2 in a subfolder. - e2catalog.py: find skin.py next to lib/ when it is not in lib/python, and read the attributes of older skin engines from applySingleAttribute (no AttributeParser class). Existing catalogs are unchanged (OpenPLi checked: same 63 attributes). Local build: HD Satelit 424 screens / 85 attributes, OpenSPA 402 screens / 124 attributes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EVc11N8zrA7gm5kdSWgpH9 --- catalogs/README.md | 2 ++ catalogs/build_catalogs.py | 14 +++++++++----- catalogs/e2catalog.py | 26 +++++++++++++++++++++++--- catalogs/images.json | 4 +++- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/catalogs/README.md b/catalogs/README.md index 70488a7..b9f65ff 100644 --- a/catalogs/README.md +++ b/catalogs/README.md @@ -33,6 +33,8 @@ URL, the `branch` and the plugin repositories scanned with it. - **Change** an image: edit its `repo` or `branch`. - **Remove** an image: set `"enabled": false`, or delete the entry. - **Plugins**: list them under `plugins`; an empty `branch` means the default branch. +- **Subfolder**: when enigma2 is not at the root of the repository (for example HD Satelit keeps + it in `enigma2/`), set `path` to that folder. ## Running it locally diff --git a/catalogs/build_catalogs.py b/catalogs/build_catalogs.py index 5522918..55164f1 100644 --- a/catalogs/build_catalogs.py +++ b/catalogs/build_catalogs.py @@ -24,8 +24,9 @@ def git(args, cwd=None): return r.stdout.strip() -def fetch(repo, branch, dest, sparse): - """Shallow clone, or update an existing one. Only the folders the catalog needs.""" +def fetch(repo, branch, dest, sparse, subdir=""): + """Shallow clone, or update an existing one. Only the folders the catalog needs. + subdir: folder of the repository that holds enigma2 (lib/python, data...), when it is not the root.""" if os.path.isdir(os.path.join(dest, ".git")): ref = branch or "HEAD" git(["fetch", "--depth", "1", "--filter=blob:none", "origin", ref], cwd=dest) @@ -38,7 +39,8 @@ def fetch(repo, branch, dest, sparse): args += ["-b", branch] git(args + [repo, dest]) if sparse: - git(["sparse-checkout", "set"] + SPARSE, cwd=dest) + prefix = subdir.strip("/") + "/" if subdir.strip("/") else "" + git(["sparse-checkout", "set"] + [prefix + p for p in SPARSE], cwd=dest) return git(["log", "-1", "--format=%ad", "--date=short"], cwd=dest) @@ -59,8 +61,10 @@ def main(): continue print(f"== {img['name']} ({img.get('branch') or 'default'})", flush=True) try: - root = os.path.join(a.cache, img["id"]) - print(" image updated on", fetch(img["repo"], img.get("branch"), root, True), flush=True) + clone = os.path.join(a.cache, img["id"]) + subdir = img.get("path", "") + print(" image updated on", fetch(img["repo"], img.get("branch"), clone, True, subdir), flush=True) + root = os.path.join(clone, subdir) if subdir else clone plugin_dirs = [] for p in img.get("plugins", []): pdir = os.path.join(a.cache, img["id"] + "__" + p["name"]) diff --git a/catalogs/e2catalog.py b/catalogs/e2catalog.py index 5e51914..1ae0e43 100644 --- a/catalogs/e2catalog.py +++ b/catalogs/e2catalog.py @@ -48,6 +48,10 @@ def parse_skin_py(path): try: tree = ast.parse(text) for node in tree.body: + # Older skin engines (e.g. HD Satelit) have no AttributeParser class: the attributes + # are the names compared with `attrib` in applySingleAttribute. + if isinstance(node, ast.FunctionDef) and node.name == "applySingleAttribute": + attributes.update(attrib_names(node)) if isinstance(node, ast.ClassDef) and node.name == "AttributeParser": for item in node.body: if isinstance(item, ast.FunctionDef) and not item.name.startswith("_") \ @@ -68,6 +72,19 @@ def parse_skin_py(path): VALUE_RE = re.compile(r"^[A-Za-z_][\w.;-]{0,39}$") +def attrib_names(func): + """Names compared with the `attrib` variable: attrib == "x" or attrib in ("x", "y").""" + names = set() + for sub in ast.walk(func): + if isinstance(sub, ast.Compare) and isinstance(sub.left, ast.Name) and sub.left.id == "attrib": + for op, comp in zip(sub.ops, sub.comparators): + if isinstance(op, ast.Eq) and isinstance(comp, ast.Constant) and isinstance(comp.value, str): + names.add(comp.value) + elif isinstance(op, ast.In) and isinstance(comp, (ast.Tuple, ast.List, ast.Set)): + names.update(e.value for e in comp.elts if isinstance(e, ast.Constant) and isinstance(e.value, str)) + return {n for n in names if re.match(r"^[A-Za-z][A-Za-z0-9_]*$", n)} + + def enum_strings(node): """String values a piece of code accepts: keys of all-string dicts, members of `x in ("a", "b")` tuples, `x == "a"` comparisons and `case "a":` patterns.""" @@ -563,13 +580,16 @@ def git_info(path): def build(root, name, plugin_dirs): py = os.path.join(root, "lib", "python") - attributes, tags = parse_skin_py(os.path.join(py, "skin.py")) + skin_py = os.path.join(py, "skin.py") + if not os.path.isfile(skin_py) and os.path.isfile(os.path.join(root, "skin.py")): + skin_py = os.path.join(root, "skin.py") # some images (HD Satelit) keep it next to lib/ + attributes, tags = parse_skin_py(skin_py) components = parse_components(os.path.join(py, "Components")) roots = [(py, "image")] + [(d, os.path.basename(os.path.normpath(d))) for d in plugin_dirs] classes, errors = collect_python(roots) screens = resolve_screens(classes) main_xml, display_xml = scan_data_xml(os.path.join(root, "data")) - deep = parse_skin_py_deep(os.path.join(py, "skin.py")) + deep = parse_skin_py_deep(skin_py) parameters, fonts = code_expectations(roots) covered = set(main_xml) @@ -578,7 +598,7 @@ def build(root, name, plugin_dirs): for s in screens: s["hasDefaultSkin"] = any(n in covered for n in s["skinNames"]) - colours = parse_colors(root, os.path.join(py, "skin.py"), screens, parameters) + colours = parse_colors(root, skin_py, screens, parameters) components["widgetAttributes"] = widget_attributes(roots) return { diff --git a/catalogs/images.json b/catalogs/images.json index 4cafdf7..ae1ed54 100644 --- a/catalogs/images.json +++ b/catalogs/images.json @@ -7,6 +7,8 @@ "plugins": [{"name": "enigma2-plugins", "repo": "https://github.com/OpenPLi/enigma2-plugins.git", "branch": ""}]}, {"id": "openvix", "name": "OpenViX", "enabled": true, "repo": "https://github.com/OpenViX/enigma2.git", "branch": "Developer", "plugins": []}, {"id": "openbh", "name": "OpenBH", "enabled": true, "repo": "https://github.com/BlackHole/enigma2.git", "branch": "Python3.14", "plugins": []}, - {"id": "teamblue", "name": "teamBlue", "enabled": true, "repo": "https://github.com/teamblue-e2/enigma2.git", "branch": "8.0", "plugins": []} + {"id": "teamblue", "name": "teamBlue", "enabled": true, "repo": "https://github.com/teamblue-e2/enigma2.git", "branch": "8.0", "plugins": []}, + {"id": "hdsatelit", "name": "HD Satelit", "enabled": true, "repo": "https://github.com/monea-software/hdsatelit-enigma2.git", "branch": "main", "path": "enigma2", "plugins": []}, + {"id": "openspa", "name": "OpenSPA", "enabled": true, "repo": "https://github.com/OpenSPA/dvbapp2.git", "branch": "master", "plugins": []} ] }