+
    ic.2  c                   s    ^ RI t ^ RIHt ^ RIHt ^ RIHtHtHtH	t	H
t
Ht . ROtRt ! R R]4      t ! R	 R
]4      t ! R R]4      t ! R R]4      t ! R R]R7      tR t ! R R]4      tRR ltR tR# )i    N)ABCMeta)get_type_hints)get_variantget_type_argumentsunwrap_variantis_base_type	StructureListDBusStructureErrorDBusDataZ__dbus_fields__c                   s    ] tR t^(tRtRtR# )r   z,General exception for DBus structure errors. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r
       5/usr/lib/python3.14/site-packages/dasbus/structure.pyr   r   (   s    6r   c                   s   a  ] tR t^-t o RtRR lt]R 4       t]R 4       t]R 4       t	]R 4       t
R tR tR	 tR
 tRtV tR# )	DBusFieldz+Description of a field in a DBus structure.c                s*    Wn         W n        W0n        R# )zCreate a description of the field.

:param name: a name of the field
:param type_hint: a type hint
:param description: a description
N)_name
_type_hint_description)selfname	type_hintdescriptions   &&&&r   __init__ZDBusField.__init__0   s     
#'r   c                    V P                   # )z$Name of the field.

:return: a name
)r   r      &r   r   ZDBusField.name;   s     zzr   c                r   )z.Type hint of the field.

:return: a type hint
)r   r   r   r   r   ZDBusField.type_hintC        r   c                r   )z2Description of the field.

:return: a description
)r   r   r   r   r   ZDBusField.descriptionK   s        r   c                s:    V P                   P                  RR4      # )zAReturn name of a data attribute.

:return: a data attribute name
-_)r   replacer   r   r   	data_nameZDBusField.data_nameS   s     yy  c**r   c                s2    \        WP                  V4       R# )zISet the data attribute.

:param obj: a data object
:param value: a value
N)setattrr#   r   objvalue   &&&r   set_dataZDBusField.set_data[   s     	^^U+r   c                s<    V P                  V\        V4      4       R# )z\Set the data attribute from a variant.

:param obj: a data object
:param variant: a variant
N)r)   r   )r   r&   variantr(   r   set_data_variantZDBusField.set_data_variantc   s     	c>'23r   c                s,    \        WP                  4      # )zDGet the data attribute.

:param obj: a data object
:return: a value
)getattrr#   r   r&      &&r   get_dataZDBusField.get_datak   s     sNN++r   c                sL    \        V P                  V P                  V4      4      # )zSGet a variant of the data attribute.

:param obj: a data object
:return: a variant
)r   r   r/   r-   r.   r   get_data_variantZDBusField.get_data_variants   s     4>>4==+=>>r   )r   r   r   NZ )r   r   r   r   r   r   propertyr   r   r   r#   r)   r+   r/   r0   r   __classdictcell____classdict__   @r   r   r   -   sv     5	(     ! ! + +,4,? ?r   r   c                   s\   a a ] tR t^|t oRtRV 3R llt]R 4       tV 3R ltR t	Rt
VtV ;t# )DBusDataFieldz0Description of a data field in a DBus structure.c                s>   < \         SV `  V\        V4       W n        R# zCreate a description of the field.

:param name: a name of the field
:param data_type: a subclass of DBusData
:param description: a description
N)superr   r   
_data_typer   r   	data_typer   	__class__   &&&&r   r   ZDBusDataField.__init__   s     	y+6#r   c                r   z=Type of the data structure.

:return: a subclass of DBusData
r:   r   r   r   r<   ZDBusDataField.data_type   r   r   c                \   < V P                   P                  V4      p\        SV `  W4       R# zSet the data attribute.N)r:   from_structurer9   r)   r   r&   r'   r=      &&&r   r)   ZDBusDataField.set_data   s$    ..u5$r   c                    V P                   P                  V P                  V4      4      p\        V P                  V4      # z$Get a variant of the data attribute.)r:   to_structurer/   r   r   r%      && r   r0   ZDBusDataField.get_data_variant   s0    ,,T]]3-?@4??E22r   r@   r1   r   r   r   r   r   r   r2   r<   r)   r0   r   r3   __classcell__r=   r5      @@r   r7   r7   |   s0     :$  %
3 3r   r7   c                   s\   a a ] tR t^t oRtRV 3R llt]R 4       tV 3R ltR t	Rt
VtV ;t# )DBusDataListFieldz5Description of a data list field in a DBus structure.c                sT   < \         SV `  V\        \        ,          V4       W n        R# r8   )r9   r   r   r   r:   r;   r>   r   r   ZDBusDataListField.__init__   s     	tI<#r   c                r   r?   r@   r   r   r   r<   ZDBusDataListField.data_type   r   r   c                rA   rB   )r:   from_structure_listr9   r)   rD   rE   r   r)   ZDBusDataListField.set_data   s$    33E:$r   c                rF   rG   )r:   to_structure_listr/   r   r   r%   rI   r   r0   Z"DBusDataListField.get_data_variant   s0    11$--2DE4??E22r   r@   r1   rJ   rL   rM   r   rN   rN      s0     ?$  %
3 3r   rN   c                   s   a a ] tR t^t oRtV 3R lt]V3R lR l4       t]V3R lR l4       t]V3R lR l4       t	]V3R	 lR
 l4       t
R tRtVtV ;t# )r	   zObject 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.
c                sp   < \         SV `  ! V/ VB  \        V \        \        P                  V 4      4       R# )zCreate a new data class.N)r9   __init_subclass__r$   DBUS_FIELDS_ATTRIBUTEDBusFieldFactorygenerate_fields)clsZargsZkwargsr=   s   &*,r   rQ   ZDBusData.__init_subclass__   s3    !4262 	!,,S1	
r   c                    < V ^8  d   QhRS[ /# )   	structurer   formatr5      "r   __annotate__DBusData.__annotate__   s      y r   c                sl   \        V\        4      '       g.   \        RP                  \	        V4      P
                  4      4      hV ! 4       p\        V 4      pVP                  4        FJ  w  rEVP                  VR4      pV'       g   \        RP                  V4      4      hVP                  W%4       KL  	  V# )zfConvert a DBus structure to a data object.

:param structure: a DBus structure
:return: a data object
Invalid type '{}'.NzField '{}' doesn't exist.)
isinstanceZdict	TypeErrorr[   typer   
get_fieldsitemsgetr   r+   )rU   rX   datafieldsr   r*   field   &&     r   rC   ZDBusData.from_structure   s     )T**$++DO,D,DE  uC&__.MDJJtT*E(/66t<  ""41 / r   c                rV   rW   returnrY   rZ   r\   r   r]   r^      s      9 r   c                s    \        W4      '       g.   \        RP                  \        V4      P                  4      4      h/ p\        V 4      pVP                  4        F  w  rEVP                  V4      W$&   K  	  V# )zIConvert this data object to a DBus structure.

:return: a DBus structure
r_   )r`   ra   r[   rb   r   rc   rd   r0   )rU   rf   rX   rg   r   rh   s   &&    r   rH   ZDBusData.to_structure   sp     $$$$++DJ,?,?@  	C!<<>KD#44T:IO * r   c                0   < V ^8  d   QhRS[ S[,          /# )rW   
structuresr   r   rZ   r\   r   r]   r^      s     9 9T)_ 9r   c                s    \        V\        4      '       g.   \        RP                  \	        V4      P
                  4      4      h\        \        V P                  V4      4      # )zwConvert DBus structures to data objects.

:param structures: a list of DBus structures
:return: a list of data objects
r_   )r`   listra   r[   rb   r   maprC   )rU   rm   r.   r   rO   ZDBusData.from_structure_list   sQ     *d++$++D,<,E,EF  C**J788r   c                rl   rj   rn   rZ   r\   r   r]   r^     s     4 44	? 4r   c                s@    \        \        V P                  V4      4      # )ztConvert data objects to DBus structures.

:param objects: a list of data objects
:return: a list of DBus structures
)ro   rp   rH   )rU   Zobjectsr.   r   rP   ZDBusData.to_structure_list  s     C(('233r   c                s    \        V 4      # )z%Convert this data object to a string.)generate_string_from_datar   r   r   __repr__ZDBusData.__repr__  s    (..r   r
   )r   r   r   r   r   rQ   classmethodrC   rH   rO   rP   rr   r   r3   rK   rL   rM   r   r	   r	      si     	
  4  $ 9 9 4 4/ /r   )Z	metaclassc                sl    \        V \        R4      pVf   \        RP                  \        4      4      hV# )z^Return DBus fields of a data object.

:param obj: a data object
:return: a map of DBus fields
NzFields are not defined at '{}'.)r,   rR   r   r[   )r&   rg   s   & r   rc   rc     s;     S/6F~ -445JK
 	
 Mr   c                   st   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tV tR	# )
rS   i)  zA DBus field factory.c                s
   / p\         P                  ! V4       FS  w  r4V P                  W44      '       g   K  V P                  V4      pV P	                  WT4      pV P                  WV4      W%&   KU  	  V'       g   \        R4      hV# )a  Generate DBus fields from properties of a class.

Properties of the class will be used to generate a map of a DBus
fields. The property should have a getter and a setter, otherwise
an error is raised. The type hint of the getter is used to define
the type of the DBus field.

:param data_class: a data class
:return: a map of DBus fields

:raise DBusStructureError: if the DBus fields cannot be generated
zNo fields found.)inspectZ
getmembers	_is_field_get_field_name_get_member_hint_create_fieldr   )rU   Z
data_classrg   member_namememberr   r   ri   r   rT   Z DBusFieldFactory.generate_fields,  s|     #*#5#5j#AK==55&&{3D,,T:I,,T=FL $B $%788r   c                sh    VP                  R4      '       d   R# \        V\        4      '       g   R# R# )zIs the member a representation of a DBus field?

:param member_name: a name of the class member
:param member: a class member
:return: True or False
r!   FT)Z
startswithr`   r2   )rU   ry   rz   r(   r   ru   ZDBusFieldFactory._is_fieldI  s-     !!#&& &(++r   c                s&    VP                  RR4      # )zrGet the name of the DBus field.

:param member_name: a name of the class member
:return: a name of the DBus field
r!   r    )r"   )rU   ry   r.   r   rv   Z DBusFieldFactory._get_field_name[  s     ""3,,r   c                sH   VP                   '       g   \        RP                  V4      4      hVP                  '       g   \        RP                  V4      4      h\	        VP                  4      pVP                  RR4      pV'       g   \        RP                  V4      4      hV# )zGet the type hint of the member.

:param field_name: a name of the DBus field
:param member: a class member
:return: a type hint
zField '{}' cannot be set.zField '{}' cannot be get.rk   NzField '{}' has unknown type.)Zfsetr   r[   Zfgetr   re   )rU   
field_namerz   Zgetter_type_hintsr   s   &&&  r   rw   Z!DBusFieldFactory._get_member_hintd  s     {{{$+22:>  {{{$+22:>  +6;;7%))(D9	$.55jA  r   c                s    \        V\        4      '       d   \        W4      # \        V\        4      '       d/   \	        V4      w  p\        V\        4      '       d   \        W4      # \        W4      # )zCreate a representation of a DBus field.

:param field_name: a name of the field
:param member_hint: a type hint of the member
:return: a new instance of DBus field
)r   r	   r7   r   r   rN   r   )rU   r{   Zmember_hintZarg_hints   &&& r   rx   ZDBusFieldFactory._create_field  sX     X.. 99T**-k:LXHh//(>>11r   r
   N)r   r   r   r   r   rs   rT   ru   rv   rw   rx   r   r3   r4   r6   r   rS   rS   )  sj      8  " - -  6 2 2r   rS   c                s   / p\        V 4      P                  4        F   pVP                  V 4      W4P                  &   K"  	  T;'       g    .  F  pVP	                  VR4       K  	  T;'       g    /  F  pW%,          W5&   K  	  \        VP                  4        UUu. uF   w  rVRP                  V\        V4      4      NK"  	  upp4      pRP                  V P                  P                  RP                  V4      4      # u uppi )a  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.

:param obj: a data object
:param skip: a list of names that should be skipped or None
:param add: a dictionary of attributes to add or None
:return: a string representation of the data object
Nz{}={}z{}({})z, )rc   Zvaluesr/   r#   ZpopZsortedrd   r[   Zreprr=   r   Zjoin)r&   ZskipZaddZ
dictionaryrh   r   r'   Z
attributess   &&&     r   rq   rq     s     JC'')&+nnS&9
??# * 


tT"  		r	9
  =G=M=M=O=OkdtT%[)=O J ??3==11499Z3HII	s   &C=
c                s    \        V \        4      ;'       d<    \        V\        4      ;'       d$    V P                  V 4      VP                  V4      8H  # )zCompare data of the given data objects.

:param obj: a data object
:param other: another data object
:return: True if the data is equal, otherwise False
)r`   r	   rH   )r&   Zotherr.   r   compare_datar|     sT     c8$ A Auh'A Ac"e&8&8&??Ar   )r   r	   rq   r|   )NN)rt   Zabcr    Ztypingr   Zdasbus.typingr   r   r   r   r   r   Z__all__rR   Z	Exceptionr   Zobjectr   r7   rN   r	   rc   rS   rq   r|   r
   r   r   <module>r}      s   *   !" " * 	 	
L? L?^3I 3@3	 3@Z/ Z/z h2v h2VJ@	Ar   