Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions catalogs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions catalogs/build_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)


Expand All @@ -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"])
Expand Down
26 changes: 23 additions & 3 deletions catalogs/e2catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("_") \
Expand All @@ -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."""
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion catalogs/images.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []}
]
}
Loading