Actually, this would even have backwards compatibility - but I haven't tested anything, so not sure if this works:
diff --git a/appstream2modaliases b/appstream2modaliases index 1c3e6a2..f7077c9 100755 --- a/appstream2modaliases +++ b/appstream2modaliases @@ -11,15 +11,13 @@ gi.require_version('AppStream', '1.0') from gi.repository import AppStream import re +pool = AppStream.Pool() +pool.load() try: - pool = AppStream.Pool() - pool.load() - cpts = pool.get_components() + cpts = pool.get_components().asArray() except AttributeError: - # Handle old API too (before version 0.10) - db = AppStream.Database() - db.open() - cpts = db.get_all_components() + # Handle old API too (before version 1.0) + cpts = pool.get_components() ma_cpts = list() fwr_cpts = list() diff --git a/isenkram/lookup.py b/isenkram/lookup.py index e10a999..eb3e4f6 100644 --- a/isenkram/lookup.py +++ b/isenkram/lookup.py @@ -71,15 +71,14 @@ def pkgs_handling_appstream_modaliases(modaliaslist): from gi.repository import AppStream except ValueError: return [] + + pool = AppStream.Pool() + pool.load() try: - pool = AppStream.Pool() - pool.load() - cpts = pool.get_components() + cpts = pool.get_components().asArray() except AttributeError: - # Handle old API too (before version 0.10) - db = AppStream.Database() - db.open() - cpts = db.get_all_components() + # Handle old API too (before version 1.0) + cpts = pool.get_components() ma_cpts = list() for cpt in cpts: provided = cpt.get_provided_for_kind(AppStream.ProvidedKind.MODALIAS)
diff --git a/appstream2modaliases b/appstream2modaliases index 1c3e6a2..f7077c9 100755 --- a/appstream2modaliases +++ b/appstream2modaliases @@ -11,15 +11,13 @@ gi.require_version('AppStream', '1.0') from gi.repository import AppStream import re +pool = AppStream.Pool() +pool.load() try: - pool = AppStream.Pool() - pool.load() - cpts = pool.get_components() + cpts = pool.get_components().asArray() except AttributeError: - # Handle old API too (before version 0.10) - db = AppStream.Database() - db.open() - cpts = db.get_all_components() + # Handle old API too (before version 1.0) + cpts = pool.get_components() ma_cpts = list() fwr_cpts = list() diff --git a/isenkram/lookup.py b/isenkram/lookup.py index e10a999..eb3e4f6 100644 --- a/isenkram/lookup.py +++ b/isenkram/lookup.py @@ -71,15 +71,14 @@ def pkgs_handling_appstream_modaliases(modaliaslist): from gi.repository import AppStream except ValueError: return [] + + pool = AppStream.Pool() + pool.load() try: - pool = AppStream.Pool() - pool.load() - cpts = pool.get_components() + cpts = pool.get_components().asArray() except AttributeError: - # Handle old API too (before version 0.10) - db = AppStream.Database() - db.open() - cpts = db.get_all_components() + # Handle old API too (before version 1.0) + cpts = pool.get_components() ma_cpts = list() for cpt in cpts: provided = cpt.get_provided_for_kind(AppStream.ProvidedKind.MODALIAS)