+
    ic/  c                   s   ^ RI HtHtHtHt ^ RIt]P                  ! RR4       ^ RIHtH	t	 . R Ot
]t]t]t]t]! R]4      t]! R]4      t]! R]4      t]! R	]4      t]! R
]4      t]! R]4      t]! R]4      t]! R]4      t]! R]4      t]]]3,          tR tR tR tR t R t!R t"R t#R t$R t% ! R R]&4      t' ! R R]&4      t( ! R R](4      t) ! R R](4      t*R# )!i    )TupleDictListNewTypeNZGLibz2.0)VariantVariantTypeByteInt16UInt16Int32UInt32Int64UInt64UnixFDObjPathVariantUnpackingVariantUnpackerVariantUnwrapperc                ,    \         P                  V 4      # )zuReturn DBus representation of a type hint.

:param type_hint: a type hint
:return: a string with DBus representation
)DBusTypeget_dbus_representation	type_hint   &2/usr/lib/python3.14/site-packages/dasbus/typing.pyget_dbus_typer   \   s     ++I66    c                sz    \        V 4      \        8X  d   T pM\        V 4      pVf   \        R4      h\	        W!4      # )a6  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
zInvalid DBus value 'None'.)typestrr   	TypeErrorr   )r   valuetype_strings   && r   get_variantr    e   s;    " I##I.}455;&&r   c                sr    \        V 4      \        8X  d   T pM\        V 4      p\        P                  ! V4      # )zzReturn a type of a variant data type.

:param type_hint: a type hint or a type string
:return: an instance of VariantType
)r   r   r   r   Znew)r   r      & r   get_variant_typer"      s.     I##I.??;''r   c                sn    \        V 4      pVP                  4       ;'       d    VP                  4       ^8H  # )zmIs the type hint a tuple of one item?

:param type_hint: a type hint or a type string
:return: True or False
)r"   Zis_tupleZn_items)r   Zvariant_typer!   r   is_tuple_of_oner#      s3     $I.L  "BB|';';'='BBr   c                s   \        V \        4      '       d   V P                  4       # \        V \        4      '       d   \        \	        \
        V 4      4      # \        V \        4      '       d   \        \	        \
        V 4      4      # \        V \        4      '       d/   V P                  4        UUu/ uF  w  rV\        V4      bK  	  upp# V # u uppi )zDecompose 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
)	Z
isinstancer   unpacktupleZmap
get_nativelistZdictitems)r   Zkv   &  r   r&   r&      s     %!!||~%SU+,,%C
E*++%-2[[];]TQ:a= ];;L <s   .Cc                r   )a%  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.

:param variant: a variant
:return: a value
)r   apply)variantr   r   unwrap_variantr-      s     !!'**r   c                sh    \        V RV 4      p W8X  d   R#  \        W4      #   \         d     R# i ; i)a/  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.

:param type_hint: a type hint
:param base_type: a base type
:return: True or False
Z
__origin__TF)getattrZ
issubclassr   r   Z	base_type   &&r   is_base_typer1      s@     	<;I)// s   
" 11c                s    \        V RR4      # )zGet 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
Z__args__ )r.   r   r   r   get_type_argumentsr3      s     9j"--r   c                s.    \        V R\        V 4      4      # )z_Get 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   get_type_namer5      s     9j#i.99r   c                   s   a  ] tR t^t o Rt]R]R]R]R]	R]
R]R]R]R	]R
]R]R]R]R/t]R]R]R/t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       tRt V t!R# )r   z0Class for transforming type hints to DBus types.ZbZsZdiZyZnZqZuZxZtZhZor)   z(%s)za%sza{%s}c                s   \         P                  V 4      '       d   \         P                  V 4      # \         P                  V 4      '       d   \         P	                  V 4      # \        RP                  \        V 4      4      4      h)zReturn 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
zInvalid DBus type '{}'.)r   _is_basic_type_get_basic_type_is_container_type_get_container_typer   formatr5   r   r   r   r   Z DBusType.get_dbus_representation  so     ""9--++I66 &&y11//	:: %,,i(
 	
r   c                s(    V \         P                  9   # )zIs it a basic type?r   _basic_type_mappingr   r   r   r7   ZDBusType._is_basic_type&  s     H8888r   c                s0    \         P                  V ,          # )zReturn a basic type.r<   r   r   r   r8   ZDBusType._get_basic_type+  s     ++I66r   c                s0    \         P                  V 4      RJ# )zIs it a container type?N)r   _get_container_base_typer   r   r   r9   ZDBusType._is_container_type0  s     00;4GGr   c                s^    \         P                   F  p\        W4      '       g   K  Vu # 	  R# )zReturn a container base type.N)r   _container_type_mappingr1   r/   r!   r   r>   Z!DBusType._get_container_base_type5  s*    
 "99II11   : r   c                s2   \         P                  V 4      p\        V 4      pV\        8X  d   \         P	                  V 4       \         P
                  V,          pV Uu. uF  p\         P                  V4      NK  	  ppVRP                  V4      ,          # u upi )zReturn a container type.Z )r   r>   r3   r   _check_if_valid_dictionaryr?   r   Zjoin)r   ZbasetypeZargsZ	containerZargr(   s   &     r   r:   ZDBusType._get_container_type@  s     44Y? "), t//	: 44X>	BFG$311#6$G2775>)) Hs   Bc                s    \        V 4      w  r\        P                  V4      '       g   V\        8X  d$   \	        RP                  \        V4      4      4      hR# )zFCheck the type of a dictionary.

:raises ValueError: for invalid type
z)Invalid DBus type of dictionary key: '{}'N)r3   r   r9   r   r   r;   r5   )r   keyZ_r*   r   r@   Z#DBusType._check_if_valid_dictionaryQ  sM     $I.&&s++sg~vmC01  0>r   r2   N)"r4   
__module____qualname____firstlineno____doc__BoolStrDoubleIntr   r   r   r	   r
   r   r   r   r   r   r=   r    r   r   r?   Zstaticmethodr   r7   r8   r9   r>   r:   r@   __static_attributes____classdictcell__Z__classdict__   @r   r   r      s     :
 	CCCCCCCCCCCCCC%0 	FEG 
 
. 9 9 7 7 H H   * *   r   r   c                   s   a  ] tR tRt o Rt]R 4       t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       tR	tV tR
# )r   i`  zSet 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.
c                s   VP                  4       pVP                  R4      '       d   V P                  ! V.VO5!  # VP                  R4      '       d   V P                  ! V.VO5!  # VP                  R4      '       d   V P                  ! V.VO5!  # VP                  R4      '       d   V P
                  ! V.VO5!  # V P                  ! V.VO5!  # )zProcess a variant.Z(za{Zar)   )Zget_type_stringZ
startswith_handle_tuple_handle_dictionary_handle_array_handle_variant_handle_value)clsr,   extrasr   s   &&* r   _process_variantZ!VariantUnpacking._process_varianth  s     --/!!#&&$$W6v66!!$''))';F;;!!#&&$$W6v66!!#&&&&w888  2622r   c                s   a aa \         ;QJ d0    . V VV3R l\        SP                  4       4       4       F  NK  	  5# ! V VV3R l\        SP                  4       4       4       4      # )zHandle a tuple.c              3   j   <"   T F(  pSP                   ! SP                  V4      .SO5!  x  K*  	  R # 5iNrU   get_child_valueZ.0r6   rS   rT   r,      & r   	<genexpr>Z1VariantUnpacking._handle_tuple.<locals>.<genexpr>~  s6      
0   !8!8!;EfEE0   03)r%   range
n_childrenrS   r,   rT      ffjr   rN   ZVariantUnpacking._handle_tuple{  sS     u 
7--/0
u 	
u 
7--/0
 
 	
r   c                s    / p\        VP                  4       4       F^  pVP                  V4      pV P                  ! VP                  ^ 4      .VO5!  pV P                  ! VP                  ^4      .VO5!  pWsV&   K`  	  V# )zHandle a dictionary.)r^   r_   rY   rU   )rS   r,   rT   Zresultr6   ZentryrA   r   s   &&*     r   rO   Z#VariantUnpacking._handle_dictionary  s     w))+,A++A.E&&u'<'<Q'?I&IC(()>)>q)AKFKE3K	 - r   c                sd   a aa \        V VV3R l\        SP                  4       4       4       4      # )zHandle an array.c              3   rV   rW   rX   rZ   r[   r   r\   Z1VariantUnpacking._handle_array.<locals>.<genexpr>  s6      
0   !8!8!;EfEE0r]   )r'   r^   r_   r`   ra   r   rP   ZVariantUnpacking._handle_array  s-      
7--/0
 
 	
r   c                sF    V P                   ! VP                  4       .VO5!  # )zHandle a variant.)rU   r    r`      &&*r   rQ   Z VariantUnpacking._handle_variant  s#     ##G$7$7$9CFCCr   c                "    VP                  4       # )zHandle a basic value.)r$   r`   rb   r   rR   ZVariantUnpacking._handle_value  s     ~~r   r2   N)r4   rB   rC   rD   rE   classmethodrU   rN   rO   rP   rQ   rR   rJ   rK   rL   rM   r   r   r   `  s      3 3$ 
 
 
 
 
 
 D D    r   c                   s4   a  ] tR tRt o Rt]R 4       tRtV tR# )r   i  zClass for unpacking variants.c                $    V P                  V4      # )z^Unpack the specified variant.

:param variant: a variant to unpack
:return: an unpacked value
rU   rS   r,   r0   r   r+   ZVariantUnpacker.apply       ##G,,r   r2   N)	r4   rB   rC   rD   rE   rd   r+   rJ   rK   rL   rM   r   r   r     s     '- -r   c                   sD   a  ] tR tRt o Rt]R 4       t]R 4       tRtV t	R# )r   i  zClass for unwrapping variants.c                re   )z^Unwrap the specified variant.

:param variant: a variant to unwrap
:return: a unwrapped value
rf   rg   r0   r   r+   ZVariantUnwrapper.apply  rh   r   c                rc   )z[Handle a variant.

Don't recursively unpack all variants.
Unpack only the topmost variant.
)r    r`   rb   r   rQ   Z VariantUnwrapper._handle_variant  s     ""$$r   r2   N)
r4   rB   rC   rD   rE   rd   r+   rQ   rJ   rK   rL   rM   r   r   r     s.     (- - % %r   )rF   rG   rH   r   rI   r   r   r	   r
   r   r   r   r   r   r   r    r   r   	Structurer&   r    r"   r#   r-   r1   r3   r   r   r   r   )+Ztypingr    r   r   r   ZgiZrequire_versionZgi.repository.GLibr   r   Z__all__ZboolrF   ZfloatrH   r   rG   ZintrI   r   r   r   r	   r
   r   r   r   r   ri   r   r    r"   r#   r&   r-   r1   r3   r5   Zobjectr   r   r   r   r2   r   r   <module>rj      s)  2 . - 	   65 ! 3D 		 
 vs	3		3		3		3	 )S
! g	7'8(C0+0.:qv qh@ v @ F
-& 
-%' %r   