Functions

  component_kind_from_string (kind_str)
  component_kind_to_string (kind)
  control_kind_from_string (kind_str)
  control_kind_to_string (kind)
  format_kind_from_string (kind_str)
  format_kind_to_string (kind)
  format_version_from_string (version_str)
  format_version_to_string (version)
  get_appstream_version ()
  get_current_distro_component_id ()
  get_default_categories (with_special)
  get_license_url (license)
  is_spdx_license_exception_id (exception_id)
  is_spdx_license_expression (license)
  is_spdx_license_id (license_id)
  license_is_free_license (license)
  license_is_metadata_license (license)
  license_to_spdx_id (license)
  markup_convert_simple (markup)
  merge_kind_from_string (kind_str)
  merge_kind_to_string (kind)
  size_kind_from_string (size_kind)
  size_kind_to_string (size_kind)
  spdx_license_detokenize (license_tokens)
  spdx_license_tokenize (license)
  urgency_kind_from_string (urgency_kind)
  urgency_kind_to_string (urgency_kind)
  url_kind_from_string (url_kind)
  url_kind_to_string (url_kind)
  utils_compare_versions (a, b)
  utils_is_category_name (category_name)
  utils_is_desktop_environment (desktop)
  utils_is_tld (tld)
  utils_locale_is_compatible (locale1, locale2)
  utils_sort_components_into_categories (cpts, categories, check_duplicates)

Details

AppStream.component_kind_from_string(kind_str)
Parameters:kind_str (str) – the string.
Returns:a AppStream.ComponentKind or AppStream.ComponentKind.UNKNOWN for unknown
Return type:AppStream.ComponentKind

Converts the text representation to an enumerated value.

AppStream.component_kind_to_string(kind)
Parameters:kind (AppStream.ComponentKind) – the AppStream.ComponentKind.
Returns:string version of kind
Return type:str

Converts the enumerated value to an text representation.

AppStream.control_kind_from_string(kind_str)
Parameters:kind_str (str) – the string.
Returns:a AppStream.ControlKind or AppStream.ControlKind.UNKNOWN for unknown
Return type:AppStream.ControlKind

Converts the text representation to an enumerated value.

New in version 0.12.11.

AppStream.control_kind_to_string(kind)
Parameters:kind (AppStream.ControlKind) – the AppStream.ControlKind.
Returns:string version of kind
Return type:str

Converts the enumerated value to a text representation.

New in version 0.12.11.

AppStream.format_kind_from_string(kind_str)
Parameters:kind_str (str) – the string.
Returns:a AppStream.FormatKind or AppStream.FormatKind.UNKNOWN for unknown
Return type:AppStream.FormatKind

Converts the text representation to an enumerated value.

New in version 0.10.

AppStream.format_kind_to_string(kind)
Parameters:kind (AppStream.FormatKind) – the AppStream.FormatKind.
Returns:string version of kind
Return type:str

Converts the enumerated value to an text representation.

New in version 0.10.

AppStream.format_version_from_string(version_str)
Parameters:version_str (str) – the string.
Returns:a AppStream.FormatVersion. For unknown, the highest version number is assumed.
Return type:AppStream.FormatVersion

Converts the text representation to an enumerated value.

New in version 0.10.

AppStream.format_version_to_string(version)
Parameters:version (AppStream.FormatVersion) – the AppStream.FormatKind.
Returns:string version of version
Return type:str

Converts the enumerated value to an text representation.

New in version 0.10.

AppStream.get_appstream_version()
Returns:The AppStream version.
Return type:str

Get the version of the AppStream library that is currently used as a string.

AppStream.get_current_distro_component_id()
Return type:str

Returns the component-ID of the current distribution based on contents of the /etc/os-release file. This function is a shorthand for AppStream.DistroDetails.get_cid

AppStream.get_default_categories(with_special)
Parameters:with_special (bool) – Include special categories (e.g. “addons”, and “all”/”featured” in submenus)
Returns:a list of AppStream.Category
Return type:[AppStream.Category]

Get a list of the default Freedesktop and AppStream categories that software components (especially GUI applications) can be sorted into in software centers.

AppStream.get_license_url(license)
Parameters:license (str) – The SPDX license ID.
Returns:The license URL.
Return type:str

Get a web URL to the license text and more license information for an SPDX license identifier.

New in version 0.12.7.

AppStream.is_spdx_license_exception_id(exception_id)
Parameters:exception_id (str) – a single SPDX license exception ID, e.g. “GCC-exception-3.1”
Returns:True if the string is a valid SPDX license exception ID
Return type:bool

Searches the known list of SPDX license exception IDs.

New in version 0.12.10.

AppStream.is_spdx_license_expression(license)
Parameters:license (str) – a SPDX license string, e.g. “CC-BY-3.0 and GFDL-1.3”
Returns:True if the icon is a valid “SPDX license”
Return type:bool

Checks the licence string to check it being a valid licence. NOTE: SPDX licenses can’t typically contain brackets.

New in version 0.9.8.

AppStream.is_spdx_license_id(license_id)
Parameters:license_id (str) – a single SPDX license ID, e.g. “GPL-3.0”
Returns:True if the string is a valid SPDX license ID
Return type:bool

Searches the known list of SPDX license IDs.

New in version 0.9.8.

AppStream.license_is_free_license(license)
Parameters:license (str) – The SPDX license string to test.
Returns:True if the license string contains only free-as-in-freedom licenses.
Return type:bool

Check if the given license is for free-as-in-freedom software. A free software license is either approved by the Free Software Foundation or the Open Source Initiative.

This function does *not* yet handle complex license expressions with AND and OR. If the expression contains any of these, it will still simply check if all mentioned licenses are Free licenses. Currently, any license exception recognized by SPDX is assumed to not impact the free-ness status of a software component.

Please note that this function does not give any legal advice. Please read the license texts to learn more about the individual licenses and their conditions.

New in version 0.12.10.

AppStream.license_is_metadata_license(license)
Parameters:license (str) – The SPDX license string to test.
Returns:True if the license contains only permissive licenses suitable as metadata license.
Return type:bool

Check if the metadata license is suitable for mixing with other metadata and redistributing the bundled result (this means we prefer permissive licenses here, to not require people shipping catalog metadata to perform a full license review).

This method checks against a hardcoded list of permissive licenses commonly used to license metadata under.

AppStream.license_to_spdx_id(license)
Parameters:license (str) – a not-quite SPDX license string, e.g. “GPLv3+”
Returns:the best-effort SPDX license string
Return type:str

Converts a non-SPDX license into an SPDX format string where possible.

New in version 0.9.8.

AppStream.markup_convert_simple(markup)
Parameters:markup (str) –
Raises:GLib.Error
Return type:str
AppStream.merge_kind_from_string(kind_str)
Parameters:kind_str (str) – the string.
Returns:a AppStream.MergeKind or AppStream.MergeKind.NONE for unknown
Return type:AppStream.MergeKind

Converts the text representation to an enumerated value.

AppStream.merge_kind_to_string(kind)
Parameters:kind (AppStream.MergeKind) – the AppStream.MergeKind.
Returns:string version of kind
Return type:str

Converts the enumerated value to an text representation.

AppStream.size_kind_from_string(size_kind)
Parameters:size_kind (str) – the string.
Returns:an AppStream.SizeKind or AppStream.SizeKind.UNKNOWN for unknown
Return type:AppStream.SizeKind

Converts the text representation to an enumerated value.

AppStream.size_kind_to_string(size_kind)
Parameters:size_kind (AppStream.SizeKind) – the AppStream.SizeKind.
Returns:string version of size_kind
Return type:str

Converts the enumerated value to an text representation.

AppStream.spdx_license_detokenize(license_tokens)
Parameters:license_tokens (str) – license tokens, typically from AppStream.spdx_license_tokenize()
Returns:string, or None for invalid
Return type:str or None

De-tokenizes the SPDX licenses into a string.

New in version 0.9.8.

AppStream.spdx_license_tokenize(license)
Parameters:license (str) – a license string, e.g. “LGPLv2+ and (QPL or GPLv2) and MIT”
Returns:array of strings, or None for invalid
Return type:[str] or None

Tokenizes the SPDX license string (or any simarly formatted string) into parts. Any license parts of the string e.g. “LGPL-2.0+” are prefexed with “@”, the conjunctive replaced with “&”, the disjunctive replaced with “|” and the WITH operator for license exceptions replaced with “^”. Brackets are added as indervidual tokens and other strings are appended into single tokens where possible.

New in version 0.9.8.

AppStream.urgency_kind_from_string(urgency_kind)
Parameters:urgency_kind (str) – the string.
Returns:a AppStream.UrgencyKind or AppStream.UrgencyKind.UNKNOWN for unknown
Return type:AppStream.UrgencyKind

Converts the text representation to an enumerated value.

New in version 0.6.5.

AppStream.urgency_kind_to_string(urgency_kind)
Parameters:urgency_kind (AppStream.UrgencyKind) – the AppStream.UrgencyKind.
Returns:string version of urgency_kind
Return type:str

Converts the enumerated value to an text representation.

New in version 0.6.5.

AppStream.url_kind_from_string(url_kind)
Parameters:url_kind (str) – the string.
Returns:a AppStream.UrlKind or AppStream.UrlKind.UNKNOWN for unknown
Return type:AppStream.UrlKind

Converts the text representation to an enumerated value.

AppStream.url_kind_to_string(url_kind)
Parameters:url_kind (AppStream.UrlKind) – the AppStream.UrlKind.
Returns:string version of url_kind
Return type:str

Converts the enumerated value to an text representation.

AppStream.utils_compare_versions(a, b)
Parameters:
Returns:

1: a is newer than b 0: a and b are the same version -1: b is newer than a

Return type:

int

Compare alpha and numeric segments of two versions. The version compare algorithm is also used by RPM.

AppStream.utils_is_category_name(category_name)
Parameters:category_name (str) –
Return type:bool
AppStream.utils_is_desktop_environment(desktop)
Parameters:desktop (str) – a desktop environment id.
Returns:True if the desktop-id is valid
Return type:bool

Searches the known list of desktop environments AppStream knows about.

New in version 0.10.0.

AppStream.utils_is_tld(tld)
Parameters:tld (str) – a top-level domain without dot, e.g. “de”, “org”, “name”
Returns:True if the TLD is valid
Return type:bool

Searches the known list of TLDs we allow for AppStream IDs. This excludes internationalized names.

New in version 0.9.8.

AppStream.utils_locale_is_compatible(locale1, locale2)
Parameters:
  • locale1 (str) – a locale string, or None
  • locale2 (str) – a locale string, or None
Returns:

True if the locale is compatible.

Return type:

bool

Calculates if one locale is compatible with another. When doing the calculation the locale and language code is taken into account if possible.

New in version 0.9.5.

AppStream.utils_sort_components_into_categories(cpts, categories, check_duplicates)
Parameters:

Sorts all components in cpts into the AppStream.Category categories listed in categories.