dasbus.typing module
- Bool
alias of
bool
- Double
alias of
float
- Int
alias of
int
- Str
alias of
str
- class Variant(format_string, value)[source]
Bases:
Variant- Constructors
new_array(child_type:GLib.VariantType=None, children:list=None) -> GLib.Variant new_boolean(value:bool) -> GLib.Variant new_byte(value:int) -> GLib.Variant new_bytestring(string:list) -> GLib.Variant new_bytestring_array(strv:list) -> GLib.Variant new_dict_entry(key:GLib.Variant, value:GLib.Variant) -> GLib.Variant new_double(value:float) -> GLib.Variant new_fixed_array(element_type:GLib.VariantType, elements=None, n_elements:int, element_size:int) -> GLib.Variant new_from_bytes(type:GLib.VariantType, bytes:GLib.Bytes, trusted:bool) -> GLib.Variant new_from_data(type:GLib.VariantType, data:list, trusted:bool, notify:GLib.DestroyNotify, user_data=None) -> GLib.Variant new_handle(value:int) -> GLib.Variant new_int16(value:int) -> GLib.Variant new_int32(value:int) -> GLib.Variant new_int64(value:int) -> GLib.Variant new_maybe(child_type:GLib.VariantType=None, child:GLib.Variant=None) -> GLib.Variant new_object_path(object_path:str) -> GLib.Variant new_objv(strv:list) -> GLib.Variant new_signature(signature:str) -> GLib.Variant new_string(string:str) -> GLib.Variant new_strv(strv:list) -> GLib.Variant new_tuple(children:list) -> GLib.Variant new_uint16(value:int) -> GLib.Variant new_uint32(value:int) -> GLib.Variant new_uint64(value:int) -> GLib.Variant new_variant(value:GLib.Variant) -> GLib.Variant
- get_string(self) str, length:int
- static new_tuple(children: list) GLib.Variant[source]
- classmethod split_signature(signature)[source]
Return a list of the element signatures of the topmost signature tuple.
If the signature is not a tuple, it returns one element with the entire signature. If the signature is an empty tuple, the result is [].
This is useful for e. g. iterating over method parameters which are passed as a single Variant.
- class VariantType(**kwargs)
Bases:
Boxed- Constructors
new(type_string:str) -> GLib.VariantType new_array(element:GLib.VariantType) -> GLib.VariantType new_dict_entry(key:GLib.VariantType, value:GLib.VariantType) -> GLib.VariantType new_maybe(element:GLib.VariantType) -> GLib.VariantType new_tuple(items:list) -> GLib.VariantType
- checked_ = gi.FunctionInfo(checked_)
- copy = gi.FunctionInfo(copy)
- dup_string = gi.FunctionInfo(dup_string)
- element = gi.FunctionInfo(element)
- equal = gi.FunctionInfo(equal)
- first = gi.FunctionInfo(first)
- free = gi.FunctionInfo(free)
- get_string_length = gi.FunctionInfo(get_string_length)
- hash = gi.FunctionInfo(hash)
- is_array = gi.FunctionInfo(is_array)
- is_basic = gi.FunctionInfo(is_basic)
- is_container = gi.FunctionInfo(is_container)
- is_definite = gi.FunctionInfo(is_definite)
- is_dict_entry = gi.FunctionInfo(is_dict_entry)
- is_maybe = gi.FunctionInfo(is_maybe)
- is_subtype_of = gi.FunctionInfo(is_subtype_of)
- is_tuple = gi.FunctionInfo(is_tuple)
- is_variant = gi.FunctionInfo(is_variant)
- key = gi.FunctionInfo(key)
- n_items = gi.FunctionInfo(n_items)
- new = gi.FunctionInfo(new)
- new_array = gi.FunctionInfo(new_array)
- new_dict_entry = gi.FunctionInfo(new_dict_entry)
- new_maybe = gi.FunctionInfo(new_maybe)
- new_tuple = gi.FunctionInfo(new_tuple)
- next = gi.FunctionInfo(next)
- string_get_depth_ = gi.FunctionInfo(string_get_depth_)
- string_is_valid = gi.FunctionInfo(string_is_valid)
- string_scan = gi.FunctionInfo(string_scan)
- value = gi.FunctionInfo(value)
- class VariantUnpacker[source]
Bases:
VariantUnpackingClass for unpacking variants.
- class VariantUnpacking[source]
Bases:
objectSet of functions of unpacking a variant.
This class is doing the same as the unpack method of the Variant class, but it allows to reuse the code for other variant modifications.
- class VariantUnwrapper[source]
Bases:
VariantUnpackingClass for unwrapping variants.
- get_dbus_type(type_hint)[source]
Return DBus representation of a type hint.
- Parameters
type_hint – a type hint
- Returns
a string with DBus representation
- get_native(value)[source]
Decompose a DBus value into a native Python object.
This function is useful for testing, when the DBus library doesn’t decompose arguments and return values of DBus calls.
- Parameters
value – a DBus value
- Returns
a native Python object
- get_type_arguments(type_hint)[source]
Get the arguments of the type hint.
For example, Str and Int are arguments of the type hint Tuple(Str, Int).
- Parameters
type_hint – a type hint
- Returns
a type arguments
- get_variant(type_hint, value)[source]
Return a variant data type.
The type of a variant is specified with a type hint.
Example:
v1 = get_variant(Bool, True) v2 = get_variant(List[Int], [1,2,3])
- Parameters
type_hint – a type hint or a type string
value – a value of the variant
- Returns
an instance of Variant
- get_variant_type(type_hint)[source]
Return a type of a variant data type.
- Parameters
type_hint – a type hint or a type string
- Returns
an instance of VariantType
- is_base_type(type_hint, base_type)[source]
Is the given base type a base of the specified type hint?
For example, List is a base of the type hint List[Int] and Int is a base of the type hint Int. A class is a base of itself and of every subclass of this class.
- Parameters
type_hint – a type hint
base_type – a base type
- Returns
True or False
- is_tuple_of_one(type_hint)[source]
Is the type hint a tuple of one item?
- Parameters
type_hint – a type hint or a type string
- Returns
True or False
- unwrap_variant(variant)[source]
Unwrap a variant data type.
Unlike the unpack method of the Variant class, this function doesn’t recursively unpacks all variants in the data structure. It will unpack only the topmost variant.
The implementation is inspired by the unpack method.
- Parameters
variant – a variant
- Returns
a value