Created
June 23, 2020 12:04
-
-
Save wjt/9fc2230bdb4705413d5fa59b276d135a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import gi | |
gi.require_version("AppStreamGlib", "1.0") | |
gi.require_version("Flatpak", "1.0") | |
from gi.repository import Gio, AppStreamGlib, Flatpak # noqa: E402 | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("xml_path") | |
args = parser.parse_args() | |
xml_file = Gio.File.new_for_path(args.xml_path) | |
store = AppStreamGlib.Store() | |
store.from_file(xml_file, None, None) | |
store.load(0) | |
for app in store.get_apps(): | |
if app.get_kind() in ( | |
AppStreamGlib.AppKind.RUNTIME, | |
AppStreamGlib.AppKind.ADDON, | |
AppStreamGlib.AppKind.GENERIC, | |
): | |
continue | |
if not app.get_content_ratings(): | |
flatpak_bundle = [ | |
bundle.get_id() | |
for bundle in app.get_bundles() | |
if bundle.get_kind() == AppStreamGlib.BundleKind.FLATPAK | |
].pop() | |
ref = Flatpak.Ref.parse(flatpak_bundle) | |
print(f"https://github.com/flathub/{ref.get_name()}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment