Utilities

Parsing utilities

sdbus.utils.parse_properties_changed(interface, properties_changed_data, on_unknown_member='error')

Parse data from properties_changed signal.

Member names will be translated to python defined names. Invalidated properties will have a value of None.

Parameters:
  • interface (DbusInterfaceBaseAsync) – Takes either D-Bus interface or interface class.

  • properties_changed_data (Tuple) – Tuple caught from signal.

  • on_unknown_member (str) – If an unknown D-Bus property was encountered either raise an "error" (default), "ignore" the property or "reuse" the D-Bus name for the member.

Return type:

Dict[str, Any]

Returns:

Dictionary of changed properties with keys translated to python names. Invalidated properties will have value of None.

sdbus.utils.parse_interfaces_added(interfaces, interfaces_added_data, on_unknown_interface='error', on_unknown_member='error')

Parse data from interfaces_added signal.

Takes an iterable of D-Bus interface classes (or a single class) and the signal data. Returns the path of new object, the class of the added object (if it matched one of passed interface classes) and the dictionary of python named properties and their values.

Parameters:
  • interfaces (Iterable[DbusInterfaceBaseAsync]) – Possible interfaces that were added. Can accept classes with multiple interfaces defined.

  • interfaces_added_data (Tuple) – Tuple caught from signal.

  • on_unknown_interface (str) – If an unknown D-Bus interface was encountered either raise an "error" (default) or return "none" instead of interface class.

  • on_unknown_member (str) – If an unknown D-Bus property was encountered either raise an "error" (default), "ignore" the property or "reuse" the D-Bus name for the member.

Return type:

Tuple[str, Optional[Type[DbusInterfaceBaseAsync]], Dict[str, Any]]

Returns:

Path of new added object, object’s class (or None) and dictionary of python translated members and their values.

sdbus.utils.parse_interfaces_removed(interfaces, interfaces_removed_data, on_unknown_interface='error')

Parse data from interfaces_added signal.

Takes an iterable of D-Bus interface classes (or a single class) and the signal data. Returns the path of removed object and the class of the added object. (if it matched one of passed interface classes)

Parameters:
  • interfaces (Iterable[DbusInterfaceBaseAsync]) – Possible interfaces that were removed. Can accept classes with multiple interfaces defined.

  • interfaces_added_data (Tuple) – Tuple caught from signal.

  • on_unknown_member (str) – If an unknown D-Bus interface was encountered either raise an "error" (default) or return "none" instead of interface class.

Return type:

Tuple[str, Optional[Type[DbusInterfaceBaseAsync]]]

Returns:

Path of removed object and object’s class (or None).

sdbus.utils.parse_get_managed_objects(interfaces, managed_objects_data, on_unknown_interface='error', on_unknown_member='error')

Parse data from get_managed_objects call.

Takes an iterable of D-Bus interface classes (or a single class) and the method returned data. Returns a dictionary where keys a paths of the managed objects and value is a tuple of class of the object and dictionary of its python named properties and their values.

Parameters:
  • interfaces (Iterable[DbusInterfaceBaseAsync]) – Possible interfaces of the managed objects. Can accept classes with multiple interfaces defined.

  • managed_objects_data (Dict) – Data returned by get_managed_objects call.

  • on_unknown_interface (str) – If an unknown D-Bus interface was encountered either raise an "error" (default) or return "none" instead of interface class.

  • on_unknown_member (str) – If an unknown D-Bus property was encountered either raise an "error" (default), "ignore" the property or "reuse" the D-Bus name for the member.

Return type:

Dict[str, Tuple[Optional[Type[DbusInterfaceBaseAsync], Dict[str, Any]]]]

Returns:

Dictionary where keys are paths and values are tuples of managed objects classes and their properties data.

New in version 0.12.0.