Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Add beta flag
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Nov 28, 2021
1 parent 686d2dd commit a9e8e3b
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 3 deletions.
23 changes: 22 additions & 1 deletion app/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@


def load_appstream():
apps = utils.appstream2dict("repo")
apps_stable = utils.appstream2dict("repo")
apps_beta = utils.appstream2dict("beta-repo")

apps = merge_apps(apps_beta, apps_stable)

current_apps = {app[5:] for app in db.redis_conn.smembers("apps:index")}
current_categories = db.redis_conn.smembers("categories:index")
Expand Down Expand Up @@ -57,6 +60,24 @@ def load_appstream():
return new_apps


def merge_apps(apps_beta, apps_stable):
apps = {}
for appid in apps_stable:
apps[appid] = apps_stable[appid]
apps[appid]["versions"] = "stable"
del apps[appid]["is_beta"]

for appid in apps_beta:
if appid not in apps:
apps[appid] = apps_beta[appid]
apps[appid]["versions"] = "beta"
del apps[appid]["is_beta"]
else:
apps[appid]["versions"] = "stable_and_beta"

return apps


def list_appstream(repo: str = "stable"):
apps = {app[5:] for app in db.redis_conn.smembers("apps:index")}
return sorted(apps)
Expand Down
4 changes: 3 additions & 1 deletion app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from . import config


def appstream2dict(reponame: str):
def appstream2dict(reponame: str) -> dict[str, object]:
if config.settings.appstream_repos is not None:
appstream_path = os.path.join(
config.settings.appstream_repos,
Expand Down Expand Up @@ -199,6 +199,8 @@ def appstream2dict(reponame: str):
appid = app["bundle"]["value"].split("/")[1]
app["id"] = appid

app["is_beta"] = reponame.startswith("beta")

apps[appid] = app

return apps
114 changes: 114 additions & 0 deletions tests/appstream/beta-repo/appstream/x86_64/appstream.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<components version="0.8" origin="flatpak">
<component type="desktop">
<id>org.sugarlabs.Maze</id>
<translation type="gettext">org.sugarlabs.Maze</translation>
<name>Maze</name>
<summary>A simple maze game</summary>
<developer_name>Sugar Labs Community</developer_name>
<description><p>Good at finding your way out of hard situations? Let&apos;s see! Try to make your way through an increasingly difficult path.</p></description>
<icon type="cached" height="64" width="64">org.sugarlabs.Maze.png</icon>
<icon type="cached" height="128" width="128">org.sugarlabs.Maze.png</icon>
<categories>
<category>Game</category>
</categories>
<kudos>
<kudo>HiDpiIcon</kudo>
</kudos>
<project_license>GPL-3.0-or-later</project_license>
<url type="bugtracker">https://github.com/sugarlabs/maze-activity</url>
<url type="homepage">https://github.com/sugarlabs/maze-activity</url>
<screenshots>
<screenshot>
<image type="source">https://i.imgur.com/imoTbzP.png</image>
<image type="thumbnail" height="351" width="624">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/624x351/org.sugarlabs.Maze-0cf71487936dec29c5b092662909f125.png</image>
<image type="thumbnail" height="63" width="112">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/112x63/org.sugarlabs.Maze-0cf71487936dec29c5b092662909f125.png</image>
<image type="thumbnail" height="126" width="224">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/224x126/org.sugarlabs.Maze-0cf71487936dec29c5b092662909f125.png</image>
<image type="thumbnail" height="423" width="752">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/752x423/org.sugarlabs.Maze-0cf71487936dec29c5b092662909f125.png</image>
</screenshot>
<screenshot type="default">
<image type="source">https://i.imgur.com/GO11pbh.png</image>
<image type="thumbnail" height="351" width="624">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/624x351/org.sugarlabs.Maze-4308958995b5f213eac85c7053e01a33.png</image>
<image type="thumbnail" height="63" width="112">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/112x63/org.sugarlabs.Maze-4308958995b5f213eac85c7053e01a33.png</image>
<image type="thumbnail" height="126" width="224">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/224x126/org.sugarlabs.Maze-4308958995b5f213eac85c7053e01a33.png</image>
<image type="thumbnail" height="423" width="752">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/752x423/org.sugarlabs.Maze-4308958995b5f213eac85c7053e01a33.png</image>
</screenshot>
<screenshot>
<image type="source">https://i.imgur.com/RH1koq6.png</image>
<image type="thumbnail" height="351" width="624">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/624x351/org.sugarlabs.Maze-5d288daae5069cde2ffe86ab4a9285a7.png</image>
<image type="thumbnail" height="63" width="112">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/112x63/org.sugarlabs.Maze-5d288daae5069cde2ffe86ab4a9285a7.png</image>
<image type="thumbnail" height="126" width="224">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/224x126/org.sugarlabs.Maze-5d288daae5069cde2ffe86ab4a9285a7.png</image>
<image type="thumbnail" height="423" width="752">https://dl.flathub.org/repo/screenshots/org.sugarlabs.Maze-stable/752x423/org.sugarlabs.Maze-5d288daae5069cde2ffe86ab4a9285a7.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1"/>
<releases>
<release timestamp="1582070400" version="30"/>
</releases>
<launchable type="desktop-id">org.sugarlabs.Maze.desktop</launchable>
<languages>
<lang percentage="100">ach</lang>
<lang percentage="100">am</lang>
<lang percentage="100">an</lang>
<lang percentage="40">ar</lang>
<lang percentage="100">ayc</lang>
<lang percentage="40">aym</lang>
<lang percentage="100">ca</lang>
<lang percentage="100">cs</lang>
<lang percentage="100">da</lang>
<lang percentage="100">de</lang>
<lang percentage="100">el</lang>
<lang percentage="100">en</lang>
<lang percentage="100">en_GB</lang>
<lang percentage="100">en_US</lang>
<lang percentage="100">es</lang>
<lang percentage="100">fa</lang>
<lang percentage="40">fi</lang>
<lang percentage="100">fr</lang>
<lang percentage="100">gn</lang>
<lang percentage="100">gug</lang>
<lang percentage="100">he</lang>
<lang percentage="100">hi</lang>
<lang percentage="100">hu</lang>
<lang percentage="40">hus</lang>
<lang percentage="100">hy</lang>
<lang percentage="100">id</lang>
<lang percentage="100">it</lang>
<lang percentage="40">ja</lang>
<lang percentage="40">kab</lang>
<lang percentage="40">km</lang>
<lang percentage="80">ko</lang>
<lang percentage="100">lt</lang>
<lang percentage="40">mg</lang>
<lang percentage="100">mi</lang>
<lang percentage="100">ml</lang>
<lang percentage="40">mn</lang>
<lang percentage="100">ms</lang>
<lang percentage="100">nah</lang>
<lang percentage="100">ne</lang>
<lang percentage="100">nl</lang>
<lang percentage="100">pap</lang>
<lang percentage="100">pbs</lang>
<lang percentage="100">pl</lang>
<lang percentage="100">pt</lang>
<lang percentage="100">pt_BR</lang>
<lang percentage="100">ro</lang>
<lang percentage="100">ru</lang>
<lang percentage="100">sk</lang>
<lang percentage="40">sl</lang>
<lang percentage="100">son</lang>
<lang percentage="100">sq</lang>
<lang percentage="40">sr</lang>
<lang percentage="100">sv</lang>
<lang percentage="40">sw</lang>
<lang percentage="40">ta</lang>
<lang percentage="60">te</lang>
<lang percentage="100">th</lang>
<lang percentage="100">uk</lang>
<lang percentage="40">vi</lang>
<lang percentage="100">zh_CN</lang>
<lang percentage="100">zh_TW</lang>
</languages>
<bundle type="flatpak" runtime="org.gnome.Platform/x86_64/3.36" sdk="org.gnome.Sdk/x86_64/3.36">app/org.sugarlabs.Maze/x86_64/stable</bundle>
</component>
</components>
7 changes: 7 additions & 0 deletions tests/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def setup_module():

installation_path = os.path.join(workspace.name, "flatpak")
repo_path = os.path.join(installation_path, "repo")
beta_repo_path = os.path.join(installation_path, "beta-repo")

os.mkdir(installation_path)
os.environ["FLATPAK_USER_DIR"] = installation_path
Expand All @@ -50,6 +51,12 @@ def setup_module():
remote_path = os.path.join(os.getcwd(), "tests/ostree/repo")
repo.remote_add("flathub", f"file://{remote_path}")

beta_file = Gio.File.new_for_path(beta_repo_path)
beta_repo = OSTree.Repo.new(beta_file)
beta_repo.create(OSTree.RepoMode.BARE, None)
beta_remote_path = os.path.join(os.getcwd(), "tests/ostree/beta-repo")
beta_repo.remote_add("flathub-beta", f"file://{beta_remote_path}")

for i, test_stats_json in enumerate(
sorted(glob.glob("tests/stats/*.json"), reverse=True)
):
Expand Down
3 changes: 2 additions & 1 deletion tests/results/test_appstream_by_appid.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
"type": "flatpak",
"runtime": "org.gnome.Platform/x86_64/3.36",
"sdk": "org.gnome.Sdk/x86_64/3.36"
}
},
"versions": "stable_and_beta"
}

0 comments on commit a9e8e3b

Please sign in to comment.