Skip to content
Snippets Groups Projects
Commit 00900372 authored by dos's avatar dos Committed by dos
Browse files

py,st3m: BundleMetadata: Rename "menu" to "category"

Old versions of py,st3m can't handle the new categories and outright
reject any bundles that use them. Allow the old "menu" key to be used
as a fallback for old firmwares.
parent a51be5ae
No related branches found
No related tags found
1 merge request!571BundleMetadata: Rename "menu" to "category"; support custom categories
......@@ -654,7 +654,7 @@ Together with the Python code this file forms a so called bundle
[app]
name = "My Demo"
menu = "Apps"
category = "Apps"
[entry]
class = "MyDemo"
......
......@@ -99,7 +99,7 @@ class BundleMetadata:
name = "Name of the application"
# One of "Apps", "Badge", "Music", "Games", "Media". Picks which menu
# the bundle's class will be loadable from.
menu = "Apps"
category = "Apps"
[entry]
# Required for app to actually load. Defines the name of the class that
......@@ -144,13 +144,12 @@ class BundleMetadata:
if "name" not in app or type(app["name"]) != str:
raise BundleMetadataBroken("missing app.name key")
self.name = app["name"]
if "category" not in app or type(app["category"]) != str:
if "menu" not in app or type(app["menu"]) != str:
raise BundleMetadataBroken("missing app.menu key")
raise BundleMetadataBroken("missing app.category key")
self.menu = app["menu"]
if self.menu not in ["Apps", "Music", "Badge", "Games", "Media", "Hidden"]:
raise BundleMetadataBroken(
"app.menu must be either Apps, Music, Badge, Games or Media"
)
else:
self.menu = app["category"]
version = 0
if t.get("metadata") is not None:
......@@ -216,11 +215,15 @@ class BundleMetadata:
raise BundleMetadataBroken("no valid entry method specified")
def menu_kinds(self) -> List[str]:
"""
Returns a list of menu kinds this bundle places its entries in.
"""
return [self.menu]
def menu_entries(self, kind: str) -> List["MenuItemAppLaunch"]:
"""
Returns MenuItemAppLauch entries for this bundle for a given menu kind.
Kind is one of 'Apps', 'Badge', 'Music', 'Games', 'Media'.
"""
if self.menu != kind:
return []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment