dasbus.structure module

class DBusData[source]

Bases: object

Object representation of data in a DBus structure.

Classes derived from this class should represent specific types of DBus structures. They will support a conversion from a DBus structure of this type to a Python object and back.

classmethod from_structure(structure: Dict[str, Variant])[source]

Convert a DBus structure to a data object.

Parameters

structure – a DBus structure

Returns

a data object

classmethod from_structure_list(structures: List[Dict[str, Variant]])[source]

Convert DBus structures to data objects.

Parameters

structures – a list of DBus structures

Returns

a list of data objects

classmethod to_structure(data) Dict[str, Variant][source]

Convert this data object to a DBus structure.

Returns

a DBus structure

classmethod to_structure_list(objects) List[Dict[str, Variant]][source]

Convert data objects to DBus structures.

Parameters

objects – a list of data objects

Returns

a list of DBus structures

exception DBusStructureError[source]

Bases: Exception

General exception for DBus structure errors.

compare_data(obj, other)[source]

Compare data of the given data objects.

Parameters
  • obj – a data object

  • other – another data object

Returns

True if the data is equal, otherwise False

generate_string_from_data(obj, skip=None, add=None)[source]

Generate a string representation of a data object.

Set the argument ‘skip’ to skip attributes with sensitive data.

Set the argument ‘add’ to add other values to the string representation. The attributes in the string representation will be sorted alphabetically.

Parameters
  • obj – a data object

  • skip – a list of names that should be skipped or None

  • add – a dictionary of attributes to add or None

Returns

a string representation of the data object