
    .Ph%                        d dl Z d dlmZ d dlmZ ddlT g dZ e j        d          Zd Z	 e j        d	          Z
d
 Z e j        d          Zd Z G d d          Z G d de          Zd Zd#dZd#dZd#dZd#dZ G d d          Z G d d          Z G d d          Z G d de          Z G d d e          Zd!efd"ZdS )$    N)Union)warn   )*)	DBusAddressnew_method_callnew_method_return	new_error
new_signalMessageGenerator
PropertiesIntrospectableDBusErrorResponsezZ([A-Za-z_-][A-Za-z0-9_-]*(\.[A-Za-z_-][A-Za-z0-9_-]*)+|:[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+))$c                     t          |           dk    r | d d         dz   }t          d|d          t                              |           st          d| d          d S )N      ...z
Bus name ( ) is too long (> 255 characters)) is not valid)len
ValueErrorbus_name_patmatchnameabbrs     P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jeepney/wrappers.pycheck_bus_namer      sw    
4yy3BQBx%NdNNNOOOd## ><d<<<===> >    z2[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)+$c                     t          |           dk    r | d d         dz   }t          d|d          t                              |           st          d| d          d S )Nr   r   r   zInterface name (r   r   )r   r   interface_patr   r   s     r   check_interfacer"   !   sz    
4yy3BQBx%TDTTTUUUt$$ DBDBBBCCCD Dr   z[A-Za-z_][A-Za-z0-9_]*$c                     t          |           dk    r | d d         dz   }t          d|d          t                              |           st          d| d          d S )Nr   r   r   zMember name (r   z is not valid)r   r   member_name_patr   r   s     r   check_member_namer%   *   sz    
4yy3BQBx%QQQQRRR  && @>>>>???@ @r   c                   &    e Zd ZdZddZd Zd ZdS )r   aA  This identifies the object and interface a message is for.

    e.g. messages to display desktop notifications would have this address::

        DBusAddress('/org/freedesktop/Notifications',
                    bus_name='org.freedesktop.Notifications',
                    interface='org.freedesktop.Notifications')
    Nc                     t                                          |           || _        |t          |           || _        |t          |           || _        d S N)ObjectPathType
check_dataobject_pathr   bus_namer"   	interface)selfr+   r,   r-   s       r   __init__zDBusAddress.__init__;   s^    ##K000&8$$$  I&&&"r   c                 t    d                     t          |           j        | j        | j        | j                  S )Nz'{}({!r}, bus_name={!r}, interface={!r}))formattype__name__r+   r,   r-   r.   s    r   __repr__zDBusAddress.__repr__G   s6    8??T

@S$dmT^E E 	Er   c                 h    t          |            t          |           | j        | j        |          S r(   )r"   r2   r+   r,   )r.   r-   s     r   with_interfacezDBusAddress.with_interfaceK   s/    	"""tDzz$*DM9EEEr   NN)r3   
__module____qualname____doc__r/   r5   r7    r   r   r   r   2   sX         
# 
# 
# 
#E E EF F F F Fr   r   c                         e Zd Zd fd	Z xZS )
DBusObjectNc                 p    t                                          |||           t          dd           d S )Nz)Deprecated alias, use DBusAddress instead   )
stacklevel)superr/   r   )r.   r+   r,   r-   	__class__s       r   r/   zDBusObject.__init__P   s9    h	:::8QGGGGGGr   r8   )r3   r9   r:   r/   __classcell__)rC   s   @r   r>   r>   O   sG        H H H H H H H H H Hr   r>   c           	      B    t          t          j        | ddddi           S )Nr   r   )flagsprotocol_versionbody_lengthserialfields)Header
Endiannesslittle)msg_types    r   
new_headerrP   T   s+    *#XQ B8 8 8 8r   r<   c                    t          |           t          t          j                  }| j        |j        t          j        <   | j        t          d          | j        |j        t          j
        <   | j        | j        |j        t          j        <   ||j        t          j        <   |||j        t          j        <   t          ||          S )a  Construct a new method call message

    This is a relatively low-level method. In many cases, this will be called
    from a :class:`MessageGenerator` subclass which provides a more convenient
    API.

    :param DBusAddress remote_obj: The object to call a method on
    :param str method: The name of the method to call
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data (i.e. method parameters)
    Nz3remote_obj.bus_name cannot be None for method calls)r%   rP   MessageTypemethod_callr+   rK   HeaderFieldspathr,   r   destinationr-   member	signatureMessage)
remote_objmethodrX   bodyheaders        r   r   r   X   s     f/00F'1'=FM,#$"NOOO.8.AFM,*+'0:0Dl,-)/FM,%&09l,-64   r   c                 <   t          t          j                  }| j        j        |j        t          j        <   | j        j                            t          j	        d          }|||j        t          j
        <   |||j        t          j        <   t          ||          S )zConstruct a new response message

    :param Message parent_msg: The method call this is a reply to
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data
    N)rP   rR   method_returnr]   rJ   rK   rT   reply_serialgetsenderrV   rX   rY   )
parent_msgrX   r\   r]   rb   s        r   r	   r	   r   s     122F/9/@/GFM,+,%)),*=tDDF28l./09l,-64   r   c                 d   t          t          j                  }| j        j        |j        t          j        <   ||j        t          j        <   | j        j        	                    t          j
        d          }|||j        t          j        <   |||j        t          j        <   t          ||          S )zConstruct a new error response message

    :param Message parent_msg: The method call this is a reply to
    :param str error_name: The name of the error
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data
    N)rP   rR   errorr]   rJ   rK   rT   r`   
error_namera   rb   rV   rX   rY   )rc   rf   rX   r\   r]   rb   s         r   r
   r
      s     )**F/9/@/GFM,+,-7FM,)*%)),*=tDDF28l./09l,-64   r   c                 V   t          |           t          t          j                  }| j        |j        t          j        <   | j        t          d          | j        |j        t          j        <   ||j        t          j
        <   |||j        t          j        <   t          ||          S )zConstruct a new signal message

    :param DBusAddress emitter: The object sending the signal
    :param str signal: The name of the signal
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data
    Nz,emitter.interface cannot be None for signals)r%   rP   rR   signalr+   rK   rT   rU   r-   r   rW   rX   rY   )emitterrh   rX   r\   r]   s        r   r   r      s     f*++F'.':FM,#$ GHHH,3,=FM,())/FM,%&09l,-64   r   c                   :    e Zd ZU dZdZee         ed<   d Zd Z	dS )r   zSubclass this to define the methods available on a DBus interface.
    
    jeepney.bindgen can automatically create subclasses using introspection.
    Nr-   c                     t                                          |           t          |           | j        t	          | j                   || _        || _        d S r(   )r)   r*   r   r-   r"   r+   r,   )r.   r+   r,   s      r   r/   zMessageGenerator.__init__   sU    ##K000x   >%DN+++& r   c                 h    d                     t          |           j        | j        | j                  S )Nz{}({!r}, bus_name={!r}))r1   r2   r3   r+   r,   r4   s    r   r5   zMessageGenerator.__repr__   s2    (//T

0C040@$-Q Q 	Qr   )
r3   r9   r:   r;   r-   Optionalstr__annotations__r/   r5   r<   r   r   r   r      sY            $Ix}###! ! !Q Q Q Q Qr   r   c                   $    e Zd ZdZd Zd Zd ZdS )	ProxyBasezA proxy is an IO-aware wrapper around a MessageGenerator
    
    Calling methods on a proxy object will send a message and wait for the
    reply. This is a base class for proxy implementations in jeepney.io.
    c                     || _         d S r(   )_msggen)r.   msggens     r   r/   zProxyBase.__init__   s    r   c                     |                     d          rt          |          t          | j        |d           }t	          |          r|                     |          S t          |          )N__)
startswithAttributeErrorgetattrrs   callable_method_call)r.   itemmake_msgs      r   __getattr__zProxyBase.__getattr__   si    ??4   	' &&&4<t44H 	/$$X...T"""r   c                      t          d          )Nz#Needs to be implemented in subclass)NotImplementedError)r.   r}   s     r   r{   zProxyBase._method_call   s    !"GHHHr   N)r3   r9   r:   r;   r/   r~   r{   r<   r   r   rq   rq      sP         
  # # #I I I I Ir   rq   c                   @    e Zd ZdZdeeef         fdZd Zd Z	d Z
dS )r   zBuild messages for accessing object properties

    If a D-Bus object has multiple interfaces, each interface has its own
    set of properties.

    This uses the standard DBus interface ``org.freedesktop.DBus.Properties``
    objc                 V    || _         t          |j        |j        d          | _        d S )Nzorg.freedesktop.DBus.Properties)r,   r-   )r   r   r+   r,   props_if)r.   r   s     r   r/   zProperties.__init__   s1    #COcl.OQ Q Qr   c                 H    t          | j        dd| j        j        |f          S )z$Get the value of the property *name*Getssr   r   r   r-   )r.   r   s     r   ra   zProperties.get   s)    t}eTH&-/ / 	/r   c                 F    t          | j        dd| j        j        f          S )z*Get all property values for this interfaceGetAllsr   r4   s    r   get_allzProperties.get_all   s'    t}h $ 246 6 	6r   c           	      N    t          | j        dd| j        j        |||ff          S )z?Set the property *name* to *value* (with appropriate signature)Setssvr   )r.   r   rX   values       r   setzProperties.set   s3    t}eUH&y%.@AC C 	Cr   N)r3   r9   r:   r;   r   r   r   r/   ra   r   r   r<   r   r   r   r      s{         QE+/?"?@ Q Q Q Q
/ / /
6 6 6
C C C C Cr   r   c                       e Zd ZdZd ZdS )r   z#org.freedesktop.DBus.Introspectablec                 "    t          | d          S )z3Request D-Bus introspection XML for a remote object
Introspect)r   r4   s    r   r   zIntrospectable.Introspect   s    t\222r   N)r3   r9   r:   r-   r   r<   r   r   r   r      s(        5I3 3 3 3 3r   r   c                       e Zd ZdZd Zd ZdS )r   z?Raised by proxy method calls when the reply is an error messagec                 z    |j         j                            t          j                  | _        |j        | _        d S r(   )r]   rK   ra   rT   rf   r   r\   data)r.   msgs     r   r/   zDBusErrorResponse.__init__   s,    J%)),*ABB	H			r   c                 B    d                     | j        | j                  S )Nz[{}] {})r1   r   r   r4   s    r   __str__zDBusErrorResponse.__str__   s    	49555r   N)r3   r9   r:   r;   r/   r   r<   r   r   r   r      s8        II  6 6 6 6 6r   r   r   c                 b    | j         j        t          j        k    rt	          |           | j        S )zGet the body of a message, raising DBusErrorResponse for error messages

    This is to be used with replies to method_call messages, which may be
    method_return or error.
    )r]   message_typerR   re   r   r\   )r   s    r   
unwrap_msgr      s,     z+"333$$$8Or   )Nr<   )retypingr   warningsr   	low_level__all__compiler   r   r!   r"   r$   r%   r   r>   rP   r   r	   r
   r   r   rq   r   r   	Exceptionr   rY   r   r<   r   r   <module>r      s   				                
 
 
 rz, 
> > > 
PQQD D D "*788@ @ @F F F F F F F F:H H H H H H H H
8 8 8! ! ! !4! ! ! ! ! ! ! !$! ! ! !(Q Q Q Q Q Q Q Q*I I I I I I I I,C C C C C C C C83 3 3 3 3% 3 3 36 6 6 6 6	 6 6 6	G 	 	 	 	 	 	r   