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)

class

new ()

add_relevant_path (path)

close ()

dir_exists (dirname)

file_exists (filename)

get_bundle_id ()

get_bundle_id_safe ()

get_bundle_kind ()

get_contents ()

get_relevant_paths ()

get_user_data ()

open ()

read_data (filename)

set_bundle_id (id)

set_bundle_kind (kind)

set_contents (contents)

set_user_data (user_data)

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:

No

Structure:

AppStreamCompose.UnitClass

classmethod new()
Return type:

AppStreamCompose.Unit

Creates a new AppStreamCompose.Unit.

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.

close()

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

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.

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.

get_bundle_id()
Return type:

str

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

get_bundle_id_safe()
Return type:

str

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.get_bundle_id()

get_bundle_kind()
Return type:

AppStream.BundleKind

Gets the bundle kind of this unit.

get_contents()
Returns:

A file listing

Return type:

[str]

Get a list of all files contained by this unit.

get_relevant_paths()
Returns:

A list of paths

Return type:

[str]

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

get_user_data()
Return type:

object or None

Get user-defined data. This is a helper function for bindings.

open()
Raises:

GLib.Error

Return type:

bool

Open this unit, populating its content listing.

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.

set_bundle_id(id)
Parameters:

id (str) – The new ID.

Sets the ID of the bundle represented by this unit.

set_bundle_kind(kind)
Parameters:

kind (AppStream.BundleKind) –

Sets the kind of the bundle this unit represents.

set_contents(contents)
Parameters:

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

Set list of files this unit contains.

set_user_data(user_data)
Parameters:

user_data (object or None) – the user data

Assign user-defined data to this object. This is a helper function for bindings.

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.

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.

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.

do_open() virtual
Return type:

bool

Open this unit, populating its content listing.

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.