AppStreamCompose.Unit

g AppStreamCompose.Unit AppStreamCompose.Unit GObject.Object GObject.Object GObject.Object->AppStreamCompose.Unit

Subclasses:

AppStreamCompose.DirectoryUnit

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

add_relevant_path (path)

close ()

dir_exists (dirname)

file_exists (filename)

get_bundle_id ()

get_bundle_id_fs_safe ()

get_bundle_kind ()

get_contents ()

get_relevant_paths ()

open ()

read_data (filename)

set_bundle_id (id)

set_bundle_kind (kind)

set_contents (contents)

Virtual Methods

Inherited:

GObject.Object (7)

do_close ()

do_dir_exists (dirname)

do_file_exists (filename)

do_open ()

do_read_data (filename)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class AppStreamCompose.Unit(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

AppStreamCompose.UnitClass

add_relevant_path(path)
Parameters:

path (str) – path to be considered relevant

Add a path to the list of relevant directories. A unit may only read data in paths that were previously registered as relevant.

Added in version 0.14.5.

close()

Close this unit, possibly freeing its resources. Calls to read_data() or get_contents() may not produce results until open() is called again.

Added in version 0.14.5.

dir_exists(dirname)
Parameters:

dirname (str) – The directory name to check.

Return type:

bool

Returns True if the directory exists and files in it are readable.

Added in version 0.14.5.

file_exists(filename)
Parameters:

filename (str) – The filename to check.

Return type:

bool

Returns True if the filename exists and is readable using AppStreamCompose.Unit.read_data.

Added in version 0.14.5.

get_bundle_id()
Return type:

str

Gets the ID name of the bundle (a package / Flatpak / any entity containing metadata) that this unit represents.

Added in version 0.14.5.

get_bundle_id_fs_safe()
Returns:

The sanitized bundle ID, or None if no bundle ID was set.

Return type:

str or None

Gets the ID name of the bundle, normalized to be safe to use in filenames. This may *not* be the same name as set via AppStreamCompose.Unit.set_bundle_id().

Added in version 0.15.1.

get_bundle_kind()
Return type:

AppStream.BundleKind

Gets the bundle kind of this unit.

Added in version 0.14.5.

get_contents()
Returns:

A file listing

Return type:

[str]

Get a list of all files contained by this unit.

Added in version 0.14.5.

get_relevant_paths()
Returns:

A list of paths

Return type:

[str]

Get a list of paths that are relevant for data processing.

Added in version 0.14.5.

open()
Raises:

GLib.Error

Return type:

bool

Open this unit, populating its content listing.

Added in version 0.14.5.

read_data(filename)
Parameters:

filename (str) – The file to read data for.

Raises:

GLib.Error

Return type:

GLib.Bytes

Read the contents of the selected file into memory and return them.

Added in version 0.14.5.

set_bundle_id(id)
Parameters:

id (str) – The new ID.

Sets the ID of the bundle represented by this unit.

Added in version 0.14.5.

set_bundle_kind(kind)
Parameters:

kind (AppStream.BundleKind)

Sets the kind of the bundle this unit represents.

Added in version 0.14.5.

set_contents(contents)
Parameters:

contents ([str]) – A list of files contained by this unit.

Set list of files this unit contains.

Added in version 0.14.5.

do_close() virtual

Close this unit, possibly freeing its resources. Calls to read_data() or get_contents() may not produce results until open() is called again.

Added in version 0.14.5.

do_dir_exists(dirname) virtual
Parameters:

dirname (str) – The directory name to check.

Return type:

bool

Returns True if the directory exists and files in it are readable.

Added in version 0.14.5.

do_file_exists(filename) virtual
Parameters:

filename (str) – The filename to check.

Return type:

bool

Returns True if the filename exists and is readable using AppStreamCompose.Unit.read_data.

Added in version 0.14.5.

do_open() virtual
Return type:

bool

Open this unit, populating its content listing.

Added in version 0.14.5.

do_read_data(filename) virtual
Parameters:

filename (str) – The file to read data for.

Return type:

GLib.Bytes

Read the contents of the selected file into memory and return them.

Added in version 0.14.5.