AppStream.Metadata¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class AppStream.Metadata(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod file_guess_style(filename)¶
- Parameters:
filename (
str
) – a file name- Returns:
An
AppStream.FormatStyle
, e.g.AppStream.FormatStyle.METAINFO
.- Return type:
Guesses the AppStream metadata style (metainfo or catalog) based on the filename.
New in version 0.14.0.
- classmethod new()¶
- Returns:
- Return type:
Creates a new
AppStream.Metadata
.
- add_component(cpt)¶
- Parameters:
cpt (
AppStream.Component
) –
Add an
AppStream.Component
to the list of components. This can be used to add multiple components in order to produce a distro-XML AppStream metadata file.
- clear_components()¶
Remove all previously parsed or manually added components.
- clear_releases()¶
Remove all previously parsed releases entries.
- component_to_metainfo(format)¶
- Parameters:
format (
AppStream.FormatKind
) – The format to use (XML or YAML)- Raises:
- Returns:
A string containing the XML metadata. Free with
GLib.free
()- Return type:
Convert an
AppStream.Component
to metainfo data. This will always be XML, YAML is no valid format for metainfo files.The amount of localization included in the metadata depends on how the
AppStream.Component
was initially loaded and whether it contains data for all locale.The first
AppStream.Component
added to the internal list will be transformed. In case no component is present,None
is returned.
- components_to_catalog(format)¶
- Parameters:
format (
AppStream.FormatKind
) – The format to serialize the data to (XML or YAML).- Raises:
- Returns:
A string containing the YAML or XML data. Free with
GLib.free
()- Return type:
Serialize all
AppStream.Component
instances into AppStream catalog metadata.None
is returned if there is nothing to serialize.
- get_component()¶
- Returns:
An
AppStream.Component
orNone
- Return type:
Gets the
AppStream.Component
which has been parsed from the XML. If the AppStream XML contained multiple components, return the last component that has been parsed.
- get_components()¶
- Returns:
an
AppStream.ComponentBox
of all parsed components- Return type:
- get_format_style()¶
- Return type:
Get the metadata parsing mode.
- get_format_version()¶
- Returns:
The AppStream metadata format version.
- Return type:
- get_locale()¶
- Returns:
Locale used for metadata parsing.
- Return type:
Gets the current active locale for parsing metadata, or “ALL” if all locales are read.
- get_parse_flags()¶
- Return type:
Get the metadata parse flags.
- get_release_list()¶
- Returns:
An
AppStream.ReleaseList
orNone
- Return type:
Gets the recently parsed
AppStream.ReleaseList
entry.
- get_release_lists()¶
- Returns:
A
GLib.PtrArray
of all parsed release metadata.- Return type:
- get_update_existing()¶
- Returns:
Whether existing components should be updates with the parsed data, instead of creating new ones.
- Return type:
- get_write_header()¶
- Returns:
Whether we will write a header/root node in catalog metadata.
- Return type:
- parse_bytes(bytes, format)¶
- Parameters:
bytes (
GLib.Bytes
) – Metadata describing one or more software components.format (
AppStream.FormatKind
) – The format of the data (XML or YAML).
- Raises:
- Returns:
True
on success.- Return type:
Parses any AppStream metadata into one or more
AppStream.Component
instances.New in version 0.14.0.
- parse_data(data, data_len, format)¶
- Parameters:
data (
str
) – Metadata describing one or more software components as string.data_len (
int
) – Length of data, or -1 if length is unknown and data isNone
-terminated.format (
AppStream.FormatKind
) – The format of the data (XML or YAML).
- Raises:
- Returns:
True
on success.- Return type:
Parses any AppStream metadata into one or more
AppStream.Component
instances.
- parse_desktop_data(cid, data, data_len)¶
- Parameters:
cid (
str
) – The component-id the newAppStream.Component
should have.data (
str
) – Metadata describing one or more software components.data_len (
int
) – The data length, or -1 if unknown and null-terminated.
- Raises:
- Returns:
True
if the file was parsed without error.- Return type:
Parses XDG Desktop Entry metadata and adds it to the list of parsed entities.
Please note that not every desktop-entry file will result in a valid component being generated, even if parsing succeeds without error (The desktiop-entry file may be valid but not generate a component on purpose).
- parse_file(file, format)¶
- Parameters:
format (
AppStream.FormatKind
) – The format the data is in, orAppStream.FormatKind.UNKNOWN
if not known.
- Raises:
- Returns:
True
if the file was parsed without error.- Return type:
Parses an AppStream upstream metadata file.
If file does not exist,
Gio.IOErrorEnum.NOT_FOUND
will be returned. OtherGLib.IOErrors
andAppStream.MetadataErrors
may be returned as appropriate.
- parse_releases_bytes(bytes)¶
- Parameters:
bytes (
GLib.Bytes
) – Metadata describing release notes.- Raises:
- Returns:
True
on success.- Return type:
Parses any AppStream release metadata into
AppStream.Release
objects. You can retrieve the last parsedAppStream.ReleaseList
usingAppStream.Metadata.get_release_list
.New in version 0.16.0.
- parse_releases_file(file)¶
- Parameters:
- Raises:
- Returns:
True
on success.- Return type:
Parses any AppStream release metadata into
AppStream.Release
objects using the provided file. You can retrieve the last parsedAppStream.ReleaseList
usingAppStream.Metadata.get_release_list
.New in version 0.16.0.
- releases_to_data(releases)¶
- Parameters:
releases (
AppStream.ReleaseList
) – theAppStream.ReleaseList
to convert.- Raises:
- Returns:
The XML representation or
None
on error.- Return type:
Convert a releases of an
AppStream.ReleaseList
entity into a release metadata XML representation.New in version 0.16.0.
- save_catalog(fname, format)¶
- Parameters:
fname (
str
) – The filename for the new metadata file.format (
AppStream.FormatKind
) –
- Raises:
- Returns:
True
if the file was written without error.- Return type:
Serialize all
AppStream.Component
instances to XML or YAML metadata and save the data to a file. An existing file at the same location will be overridden.
- save_metainfo(fname, format)¶
- Parameters:
fname (
str
) – The filename for the new metadata file.format (
AppStream.FormatKind
) – The format to save this file in. Only XML is supported at time.
- Raises:
- Returns:
True
if the file was written without error.- Return type:
Serialize
AppStream.Component
instance to XML and save it to file. An existing file at the same location will be overridden.
- set_architecture(arch)¶
- Parameters:
arch (
str
) – an architecture string.
Set the architecture the components in this metadata belong to.
- set_format_style(mode)¶
- Parameters:
mode (
AppStream.FormatStyle
) – theAppStream.FormatStyle
.
Sets the current metadata parsing mode.
- set_format_version(version)¶
- Parameters:
version (
AppStream.FormatVersion
) – the AppStream metadata format version asAppStream.FormatVersion
.
Set the current AppStream format version that we should generate data for or be able to read.
- set_locale(locale)¶
- Parameters:
locale (
str
) – the BCP47 locale.
Sets the locale which should be read when processing metadata. All other locales are ignored, which increases parsing speed and reduces memory usage. If you set the locale to “ALL”, all locales will be read.
- set_media_baseurl(url)¶
- Parameters:
url (
str
) – the base URL.
Set the base URL for all media links referenced in the metadata, or
None
if every component has absolute URLs.
- set_origin(origin)¶
- Parameters:
origin (
str
) – the origin of AppStream distro metadata.
Set the origin of AppStream distro metadata
- set_parse_flags(flags)¶
- Parameters:
flags (
AppStream.ParseFlags
) – theAppStream.ParseFlags
.
Sets the current metadata parse flags.
- set_update_existing(update)¶
- Parameters:
update (
bool
) – A boolean value.
If set to
True
, the parser will not create new components but instead update existing components in the pool with new metadata.NOTE: Right now, this feature is only implemented for metainfo XML parsing!
- set_write_header(wheader)¶
- Parameters:
wheader (
bool
) – A boolean value.
If set to
True
, tehe metadata writer will omit writing a DEP-11 header document when in YAML mode, and will not write a root components node when writing XML data. Please keep in mind that this will create an invalid DEP-11 YAML AppStream catalog metadata file, and an invalid XML file. This parameter should only be changed e.g. by the appstream-generator tool.NOTE: Right now, this feature is only implemented for YAML!