
    .Ph                         d Z ddlZddlZddlZddlmc mZ ddl	m
Z
 ddlmZ ddlmZmZ ddlmZ  G d d          Zd	Z G d
 d          ZdZh dZd ZddZd Zd Zedk    r e             dS dS )z5Generate a wrapper class from DBus introspection data    N)indent)Introspectable)open_dbus_connectionProxy)__version__c                        e Zd Zd Zd Zd ZdS )Methodc                    |j         d         | _        g | _        g | _        |                    d          D ]}	 |j         d         }n7# t
          $ r* d                    t          | j                            }Y nw xY w| j                            |           | j                            |j         d                    d S )Nnamezarg[@direction='in']zarg{}type)	attribr   in_args	signaturefindallKeyErrorformatlenappend)selfxml_nodeargr   s       O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jeepney/bindgen.py__init__zMethod.__init__   s    OF+	##$:;; 	6 	6C9z&) 9 9 9~~c$,&7&7889L%%%N!!#*V"45555	6 	6s   A1A;:A;c                 8    d                     | j                  S )Nz=def {name}(self):
    return new_method_call(self, '{name}')
)r   )r   r   )r   s    r   _make_code_noargszMethod._make_code_noargs   s)    ?@F AG A A	    c                 :   | j         s|                                 S d                    | j                   }d                    | j                  }t	          | j                   dk    rdnd                    |          }d                    | j        |||          S )Nz,     z({},)z({})zxdef {name}(self, {args}):
    return new_method_call(self, '{name}', '{signature}',
                           {tuple})
)r   argsr   tuple)r   r   joinr   r   r   r   )r   r    r   r!   s       r   	make_codezMethod.make_code   s    | 	,))+++yy&&GGDN++	--22FFtLL89?% :@ :
 :
	
r   N)__name__
__module____qualname__r   r   r#    r   r   r	   r	      sA        
6 
6 
6  

 
 
 
 
r   r	   z
class {cls_name}(MessageGenerator):
    interface = {interface!r}

    def __init__(self, object_path{path_default},
                 bus_name{name_default}):
        super().__init__(object_path=object_path, bus_name=bus_name)
c                       e Zd Zd Zd ZdS )	Interfacec                     |j         d         | _        || _        || _        d |                    d          D             | _        d S )Nr   c                 ,    g | ]}t          |          S r'   )r	   ).0nodes     r   
<listcomp>z&Interface.__init__.<locals>.<listcomp>9   s    LLLtLLLr   method)r   r   pathbus_namer   methods)r   r   r0   r1   s       r   r   zInterface.__init__5   sE    OF+		 LL1A1A(1K1KLLLr   c                 v   | j                             d          d         }t                              || j         | j        dn	d| j        | j        dn	d| j                  g}| j        D ]7}|                    t          |	                                d                     8d
                    |          S )N.r   =)cls_name	interfacepath_defaultname_defaultz    
)r   splitINTERFACE_CLASS_TEMPLATEr   r0   r1   r2   r   r   r#   r"   )r   r7   chunksr/   s       r   r#   zInterface.make_code;   s    9??3''+*11i#y06G$)6G6G#}4:Odm:O:O	 2 
 
  l 	? 	?FMM&!1!1!3!3W==>>>>yy   r   N)r$   r%   r&   r   r#   r'   r   r   r)   r)   4   s5        M M M
! 
! 
! 
! 
!r   r)   z"""Auto-generated DBus bindings

Generated by jeepney version {version}

Object path: {path}
Bus name   : {bus_name}
"""

from jeepney.wrappers import MessageGenerator, new_method_call

>   org.freedesktop.DBus.Peerorg.freedesktop.DBus.Properties#org.freedesktop.DBus.Introspectablec                    t          |t          t          f          r:t          |d          5 }t	          | |||          cd d d            S # 1 swxY w Y   t          j        |           }|                    t          	                    t          ||                     d}|                    d          D ]R}|j        d         t          v r|                    t          |||                                                     |dz  }S|S )Nw)versionr0   r1   r   r8   r   r   )
isinstancebytesstropencode_from_xmlET
fromstringwriteMODULE_TEMPLATEr   r   r   r   IGNORE_INTERFACESr)   r#   )xmlr0   r1   fhfrootiinterface_nodes           r   rI   rI   [   sF   "ucl## 9"c]] 	9a dHa88	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 =DHH_##Kd-5 $ 7 7 8 8 8 	
A,,{33   (,===
>4::DDFFGGG	QHs   AAASESSIONc                 ,   | sd|                     dd          z   } t          |          }t          t          | |          |          }|                                \  }t          || ||          }t          d                    ||                     d S )N/r4   #Written {} interface wrappers to {})replacer   r   r   
IntrospectrI   printr   )r0   r   output_filebusconnintrospectablerO   n_interfacess           r   generate_from_introspectionra   m   s      ,T\\#s+++$$D>$55t<<N$$&&DC !dD+>>L	
/
6
6|[
Q
QRRRRRr   c                     t          | d          5 }|                                }d d d            n# 1 swxY w Y   t          ||||          }t          d                    ||                     d S )Nzutf-8)encodingrX   )rH   readrI   r[   r   )
input_filer0   r   r\   rQ   rO   r`   s          r   generate_from_filerf   {   s    	j7	+	+	+ qffhh               !dD+>>L	
/
6
6|[
Q
QRRRRRs   377c                     t          j        dd          } |                     ddd           |                     dd	d
           |                     ddd           |                     ddd           |                     ddd           |                                 }|j        s|j        st          j        d           |j        r|j        }n|j        rKt          j
                            t          j
                            |j                            d         dz   }nd|j
        r?t          |j
                  dk    r'|j
        dd                              dd          dz   }n|j                            dd          dz   }|j        r#t          |j        |j
        |j        |           d S t!          |j
        |j        ||j                   d S )Nz7Generate a simple wrapper module to call D-Bus methods.zIf you don't use --file, this will connect to D-Bus and introspect the given name and path. --name and --path can also be used with --file, to give defaults for the generated class.)descriptionepilogz-nz--namez2Bus name to introspect, required unless using file)helpz-pz--pathzObject path to introspect. If not specified, a path matching the name will be used, e.g. /org/freedesktop/Notifications for org.freedesktop.Notificationsz--busrU   zEBus to connect to for introspection (SESSION/SYSTEM), default SESSION)defaultrj   z-fz--filez.XML file to use instead of D-Bus introspectionz-oz--outputzOutput filenamez#Either --name or --file is requiredr   z.pyr   rW   _r4   )argparseArgumentParseradd_argument
parse_argsfiler   sysexitoutputosr0   splitextbasenamer   rY   rf   ra   r]   )apr    rt   s      r   mainry      s
   		 M;
 
 
B OOD(M  O O OOOD(x  y y y OOGY`  b b bOOD(I  K K KOOD**  , , ,==??DI 8 86777 { 5	 5!!"'"2"249"="=>>qAEI	 5s49~~))122&&sC0058""3,,u4y L49diFCCCCC#DIty&$(KKKKKr   __main__)rU   )__doc__rm   os.pathru   rr   xml.etree.ElementTreeetreeElementTreerJ   textwrapr   jeepney.wrappersr   jeepney.io.blockingr   r   jeepneyr   r	   r=   r)   rM   rN   rI   ra   rf   ry   r$   r'   r   r   <module>r      sp   ; ;   



 " " " " " " " " "       + + + + + + ; ; ; ; ; ; ; ;      
 
 
 
 
 
 
 
> ! ! ! ! ! ! ! !&     $S S S SS S S$L $L $LN zDFFFFF r   