grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a Êic‹/ã@sFddlmZmZmZmZddlZe dd¡ddlmZm Z gd¢Z e Z e ZeZeZedeƒZedeƒZed eƒZed eƒZed eƒZed eƒZed eƒZedeƒZedeƒZeeefZdd„Zdd„Zdd„Zdd„Z dd„Z!dd„Z"dd„Z#dd„Z$d d!„Z%Gd"d#„d#e&ƒZ'Gd$d%„d%e&ƒZ(Gd&d'„d'e(ƒZ)Gd(d)„d)e(ƒZ*dS)*é)ÚTupleÚDictÚListÚNewTypeNZGLibz2.0)ÚVariantÚ VariantType)ÚBoolÚStrÚDoubleÚByteÚIntÚInt16ÚUInt16ÚInt32ÚUInt32ÚInt64ÚUInt64ÚUnixFDÚObjPathrrrrrÚ StructureÚ get_nativeÚ get_variantÚget_variant_typeÚis_tuple_of_oneÚunwrap_variantÚ is_base_typeÚget_type_argumentsÚ get_dbus_typeÚVariantUnpackingÚVariantUnpackerÚVariantUnwrapperr r rrrrrrrcCs t |¡S)z�Return DBus representation of a type hint. :param type_hint: a type hint :return: a string with DBus representation ©ÚDBusTypeÚget_dbus_representation©Ú type_hint©r&ú1/usr/lib/python3.9/site-packages/dasbus/typing.pyr\srcCs4t|ƒtkr|}nt|ƒ}|dur*tdƒ‚t||ƒS)a^Return a variant data type. The type of a variant is specified with a type hint. Example: .. code-block:: python v1 = get_variant(Bool, True) v2 = get_variant(List[Int], [1,2,3]) :param type_hint: a type hint or a type string :param value: a value of the variant :return: an instance of Variant NzInvalid DBus value 'None'.)ÚtypeÚstrrÚ TypeErrorr)r%ÚvalueÚ type_stringr&r&r'res  rcCs$t|ƒtkr|}nt|ƒ}t |¡S)z†Return a type of a variant data type. :param type_hint: a type hint or a type string :return: an instance of VariantType )r(r)rrÚnew)r%r,r&r&r'r�s rcCst|ƒ}| ¡o| ¡dkS)zyIs the type hint a tuple of one item? :param type_hint: a type hint or a type string :return: True or False é)rZis_tupleZn_items)r%Z variant_typer&r&r'r�srcCsbt|tƒr| ¡St|tƒr*ttt|ƒƒSt|tƒrBttt|ƒƒSt|tƒr^dd„| ¡DƒS|S)zý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. :param value: a DBus value :return: a native Python object cSsi|]\}}|t|ƒ“qSr&)r)Ú.0ÚkÚvr&r&r'Ú ¬ózget_native..) Ú isinstancerÚunpackÚtupleÚmaprÚlistÚdictÚitems)r+r&r&r'r™s    rcCs t |¡S)aAUnwrap 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. :param variant: a variant :return: a value )r Úapply)Úvariantr&r&r'r±s rcCs<t|d|ƒ}||krdSz t||ƒWSty6Yn0dS)aKIs 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. :param type_hint: a type hint :param base_type: a base type :return: True or False Ú __origin__TF)ÚgetattrÚ issubclassr*©r%Z base_typer&r&r'rÀs   rcCs t|ddƒS)z·Get the arguments of the type hint. For example, Str and Int are arguments of the type hint Tuple(Str, Int). :param type_hint: a type hint :return: a type arguments Ú__args__r&)r>r$r&r&r'rØsrcCst|dt|ƒƒS)zkGet the name of the type hint. :param type_hint: a type hint :return: a name of the type hint Ú__name__)r>r)r$r&r&r'Ú get_type_nameãsrCc@s°eZdZdZededededede de de de d e d ed ed ed ediZededediZedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZd S)!r"z0Class for transforming type hints to DBus types.ÚbÚsÚdÚiÚyÚnÚqÚuÚxÚtÚhÚor1z(%s)za%sza{%s}cCs>t |¡rt |¡St |¡r(t |¡Std t|ƒ¡ƒ‚dS)zÏReturn a DBus representation of the given type hint. :param type_hint: a type hint :return str: a DBus representation of the type hint :raises ValueError: for unknown types zInvalid DBus type '{}'.N)r"Ú_is_basic_typeÚ_get_basic_typeÚ_is_container_typeÚ_get_container_typer*ÚformatrCr$r&r&r'r#s    ÿÿz DBusType.get_dbus_representationcCs |tjvS)zIs it a basic type?©r"Ú_basic_type_mappingr$r&r&r'rP&szDBusType._is_basic_typecCs tj|S)zReturn a basic type.rUr$r&r&r'rQ+szDBusType._get_basic_typecCst |¡duS)zIs it a container type?N)r"Ú_get_container_base_typer$r&r&r'rR0szDBusType._is_container_typecCs"tjD]}t||ƒr|SqdS)zReturn a container base type.N)r"Ú_container_type_mappingrr@r&r&r'rW5s   z!DBusType._get_container_base_typecCsJt |¡}t|ƒ}|tkr$t |¡tj|}dd„|Dƒ}|d |¡S)zReturn a container type.cSsg|]}t |¡‘qSr&r!)r/Úargr&r&r'Ú Nr3z0DBusType._get_container_type..Ú)r"rWrrÚ_check_if_valid_dictionaryrXÚjoin)r%ZbasetypeÚargsÚ containerr:r&r&r'rS@s   zDBusType._get_container_typecCs4t|ƒ\}}t |¡s|tkr0td t|ƒ¡ƒ‚dS)zVCheck the type of a dictionary. :raises ValueError: for invalid type z)Invalid DBus type of dictionary key: '{}'N)rr"rRrr*rTrC)r%ÚkeyÚ_r&r&r'r\Qs ÿÿz#DBusType._check_if_valid_dictionaryN)rBÚ __module__Ú __qualname__Ú__doc__rr r r r r rrrrrrrrrVrrrrXÚ staticmethodr#rPrQrRrWrSr\r&r&r&r'r"ìsDîý      r"c@sXeZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZed d „ƒZ ed d „ƒZ dS)rzÃSet 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. cGsŠ| ¡}| d¡r$|j|g|¢RŽS| d¡r@|j|g|¢RŽS| d¡r\|j|g|¢RŽS| d¡rx|j|g|¢RŽS|j|g|¢RŽS)zProcess a variant.ú(za{Úar1)Zget_type_stringÚ startswithÚ _handle_tupleÚ_handle_dictionaryÚ _handle_arrayÚ_handle_variantÚ _handle_value)Úclsr<Úextrasr,r&r&r'Ú_process_varianths    z!VariantUnpacking._process_variantcs"t‡‡‡fdd„tˆ ¡ƒDƒƒS)zHandle a tuple.c3s&|]}ˆjˆ |¡gˆ¢RŽVqdS©N©rpÚget_child_value©r/rG©rnror<r&r'Ú ~sÿz1VariantUnpacking._handle_tuple..)r6ÚrangeÚ n_children©rnr<ror&rur'ri{s þzVariantUnpacking._handle_tuplecGs\i}t| ¡ƒD]F}| |¡}|j| d¡g|¢RŽ}|j| d¡g|¢RŽ}|||<q|S)zHandle a dictionary.rr.)rwrxrsrp)rnr<roÚresultrGÚentryr`r+r&r&r'rjƒs  z#VariantUnpacking._handle_dictionarycs"t‡‡‡fdd„tˆ ¡ƒDƒƒS)zHandle an array.c3s&|]}ˆjˆ |¡gˆ¢RŽVqdSrqrrrtrur&r'rv“sÿz1VariantUnpacking._handle_array..)r8rwrxryr&rur'rk�s þzVariantUnpacking._handle_arraycGs|j| ¡g|¢RŽS)zHandle a variant.)rprryr&r&r'rl˜sz VariantUnpacking._handle_variantcGs| ¡S)zHandle a basic value.)r5ryr&r&r'rm�szVariantUnpacking._handle_valueN) rBrbrcrdÚ classmethodrprirjrkrlrmr&r&r&r'r`s     rc@seZdZdZedd„ƒZdS)rzClass for unpacking variants.cCs | |¡S)zvUnpack the specified variant. :param variant: a variant to unpack :return: an unpacked value ©rp©rnr<r&r&r'r;¦szVariantUnpacker.applyN)rBrbrcrdr|r;r&r&r&r'r£src@s(eZdZdZedd„ƒZedd„ƒZdS)r zClass for unwrapping variants.cCs | |¡S)zvUnwrap the specified variant. :param variant: a variant to unwrap :return: a unwrapped value r}r~r&r&r'r;³szVariantUnwrapper.applycGs| ¡S)zsHandle a variant. Don't recursively unpack all variants. Unpack only the topmost variant. )rryr&r&r'rl¼sz VariantUnwrapper._handle_variantN)rBrbrcrdr|r;rlr&r&r&r'r °s  r )+ÚtypingrrrrZgiZrequire_versionZgi.repository.GLibrrÚ__all__ÚboolrÚfloatr r)r Úintr r r rrrrrrrrrrrrrrrrrCÚobjectr"rrr r&r&r&r'Ús> "              tC