+
    WBi                       a  R t10 t R tRtRt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHt ^ RIHtHtHtHtHtHtHt ^ RIHt ^ RIt^ RIt] / t] ^ k RtRt]]]3,          t]]]]]3,          t ]]!]]],          3,          t"R	 R
 lt#R R lt$R t%R t&R R lt'R t( ! R R]PR                  PT                  4      t+]PR                  PX                  t-R t.].]PR                  n,        R R lt/R R lt0R# )z#Mock D-Bus objects for test suites.zMartin PittzH
(c) 2012 Canonical Ltd.
(c) 2017 - 2022 Martin Pitt <martin@piware.de>
N)Path)AnyDictKeysViewListOptionalSequenceTuple)ElementTreezorg.freedesktop.DBus.Mockz"org.freedesktop.DBus.ObjectManagerc                0    V ^8  d   QhR\         R\        /# )   pathtemplate_name)r   str)formats   "8/usr/lib/python3.14/site-packages/dbusmock/mockobject.py__annotate__r   /   s       S     c                    \         P                  P                  W4      pV'       g   Q h\         P                  P                  V4      p\	        V P                  R4      VP                  VP                  4       V# )z%Load a mock template from a file pathzUTF-8)	importlibutilspec_from_file_locationmodule_from_specexec	read_text__dict__)r   r   specmods   &&  r   load_module_from_pathr   /   sS    >>11-FDK4
..
)
)$
/C	 #,,=Jr   c                $    V ^8  d   QhR\         /# )r   namer   )r   s   "r   r   r   8   s     A Ac Ar   c                   \        V 4      pVP                  4       '       d'   VP                  R8X  d   \        WP                  4      # \
        P                  P                  R4      ;'       g    RpVP                  R4       F;  p\        VRRV R,           4      pVP                  4       '       g   K0  \        W@4      u # 	  \        P                  ! RV ,           4      # )zLoad a mock template Python module

This can be a path to the template's .py file, a bare module name in
``$XDG_DATA_DIRS/python-dbusmock/templates/``, or a bare module name in dbusmock's shipped templates.
z.pyXDG_DATA_DIRSz/usr/local/share/:/usr/share/:zpython-dbusmock	templateszdbusmock.templates.)r   existssuffixr   stemosenvirongetsplitr   import_module)r    pnamexdg_data_dirsdsrcs   &    r   load_moduler2   8   s     JE||~~%,,%/$UJJ77 JJNN?3VV7VM  %1'dUlC::<<(33 & ""#84#?@@r   c                   a V3R loRpV  F#  pV'       d
   VR,          pVS! V4      ,          pK%  	  V'       d
   RV,           pV# )z@Format a D-Bus argument tuple into an appropriate logging stringc           	        < \        V \        P                  4      '       d   \        \	        V 4      4      # \        V \        P
                  \        34      '       d   \        \        V 4      4      # \        V \        4      '       d   R \        V 4      ,           R ,           # \        V \        4      '       d6   RRP                  V  Uu. uF  pS! V4      NK  	  up4      ,           R,           # \        V \        4      '       d^   RpRpV P                  4        F<  w  rEV'       d   RpM	VR,          pVS! V4      R,           S! V4      ,           ,          pK>  	  VR,           # \        V 4      # u upi )	"[z, ]{TF: })
isinstancedbusBooleanr   boolByteintlistjoindictitemsrepr)axfmtafirstkv
format_args   &     r   rL    _format_args.<locals>.format_argQ   s   a&&tAw<a$))S)**s1v;aQ<#%%a1#=1aJqM1#=>>DDaDE	!EDLD
1,z!}<< " #: Aw $>s   E(
   )argssrF   rL   s   &  @r   _format_argsrS   N   sF    . 	AHA	Z]  	!GHr   c                    \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P
                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  \         P                  P                  .p\         P                  P                   \         P                  P"                  \         P                  P$                  .p\'        V \         P                  4      '       d"   \         P                  ! \)        V 4      ^R7      # \+        V 4      V9   d   V # \+        V 4      V9   d"   \+        V 4      ! V P-                  4       ^R7      # \'        V \(        4      '       d   \         P                  ! V ^R7      # \         P.                  P1                  R\+        V 4       24      h)   )variant_levelzcould not wrap type )r<   types	ByteArrayInt16
ObjectPathUInt64r=   Int32	SignatureUInt16UnixFdr?   DoubleInt64StringUInt32ArrayStruct
Dictionaryr;   r   type	conjugate
exceptionsDBusException)value
dbus_typescontainer_typess   &  r   _wrap_in_dbus_variantrn   r   s   



























J" 	





O
 %%%{{3u:Q77E{o%E{j E{5??,A>>%{{522
//
'
'*>tE{m(L
MMr   c                l    V ^8  d   QhR\         R\        \        R3,          R\        \        ,          /# )r   	signaturerQ   .return)r   r	   r   r   )r   s   "r   r   r      s-      S c3h DI r   c                B    V R8X  d   \        V4      ^ 8  d   \        R4      h\        P                  P	                  RRRR4      pVP
                  ! VRV /  VP                  4       #   \         d,   p\        P                  P                  RT: 2RR	7      ThR
p?ii ; i)z
Convert types of arguments according to signature, using
MethodCallMessage.append(); this will also provide type/length
checks, except for the case of an empty signature
rN   z=Fewer items found in D-Bus signature than in Python argumentsza.bz/arF   rp   zInvalid arguments: z&org.freedesktop.DBus.Error.InvalidArgsr    N)
len	TypeErrorr<   
connectionMethodCallMessageappendget_args_list	Exceptionri   rj   )rp   rQ   mes   &&  r   _convert_argsr}      s    	?s4y1}[\\OO--eT5#F	$,),   oo++!!'.V , 
	s   A%A( (B3&BBc                J   a a \         P                  ! S4      VV 3R l4       pV# )z-Decorator for a method to end in the call logc                  Z  < SP                   pV ^ ,          V R,          r\        SRR4      p\        W@4      p SP                  V\	        V 4      ,           4       SP
                  P                  \        \        P                  ! 4       4      W 34       SP                  W 4       S! V.V O/ VB # )    :rU   NN_dbus_in_signaturerN   )
__name__getattrr}   logrS   call_logrx   r@   timeMethodCalled)rQ   kwargsfnameself_argin_signaturefuncselfs   *,   r   wrapperloggedmethod.<locals>.wrapper   s    a$r($t%92>\0d++,c$))+.<=%&h&&1&11r   )	functoolswraps)r   r   r   s   ff r   loggedmethodr      s'     __T2 2 Nr   c                   R  a  ] tR t^t o RtRPV 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 lt]	P                  P                  ]	P                  RRR7      V 3R lR l4       t]	P                  P                  ]	P                  RRR7      V 3R lR l4       t]	P                  P                  ]	P                  RRR7      V 3R lR l4       t]	P                  P                  ]RRR7      V 3R lR l4       t]	P                  P                  ]RRR7      V 3R lR l4       t]	P                  P                  ]RRR7      V 3R lR l4       t]	P                  P                  ]RRR7      V 3R  lR! l4       t]	P                  P                  ]R"RR7      V 3R# lR$ l4       tR% t]	P                  P                  ]R&RR7      V 3R' lR( l4       t]	P                  P                  ]RRR7      V 3R) lR* l4       t]	P                  P                  ]R&RR7      V 3R+ lR, l4       t]	P                  P                  ]R&RR7      V 3R- lR. l4       tV 3R/ lR0 lt]	P                  P                  ]R1RR7      V 3R2 lR3 l4       t]	P                  P                  ]R4RR7      V 3R5 lR6 l4       t]	P                  P                  ]RR7R7      V 3R8 lR9 l4       t]	P                  P                  ]RR:R7      V 3R; lR< l4       t]	P                  P                  ]RRR7      V 3R= lR> l4       t ]	P                  PC                  ]R?R@7      RA 4       t"V 3RB lRC lt#V 3RD lRE lt$V 3RF lRG lt%V 3RH lRI lt&]	P                  P                  ]	PN                  RRRJRKRL7      V 3RM lRN l4       t(ROt)V t*R# )QDBusMockObjecta  Mock D-Bus object

This can be configured to have arbitrary methods (including code execution)
and properties via methods on the org.freedesktop.DBus.Mock interface, so
that you can control the mock from any programming language.

Beyond that "remote control" API, this is a standard
`dbus-python service object <https://dbus.freedesktop.org/doc/dbus-python/tutorial.html#exporting-objects>`_.
Nc                X   < V ^8  d   QhRS[ RS[ RS[ RS[RS[S[ ,          RS[RS[RR	/# )
r   bus_namer   	interfacepropslogfileis_object_manager	mock_datarq   N)r   	PropsTyper   r>   r   )r   __classdict__s   "r   r   DBusMockObject.__annotate__   s_     1 11 1 	1
 1 #1  1 1 
1r   c                @   \         P                  P                  P                  WV4       Wn        W n        W0n        W`n        RV n        RV n	        RV n
        V'       d   \        VR4      MRV n        RV n        . V n        Wpn        Vf   / pV P!                  V4       R# )u  Create a new DBusMockObject

:param bus_name: A dbus.service.BusName instance where the object will be put on
:param path: D-Bus object path
:param interface: Primary D-Bus interface name of this object (where
                  properties and methods will be put on)
:param props: A property_name (string) → property (Variant) map with initial
              properties on "interface"
:param logfile: When given, method calls will be logged into that file name;
                if None, logging will be written to stdout. Note that you can
                also query the called methods over D-Bus with GetCalls() and
                GetMethodCalls().
:param is_object_manager: If True, the GetManagedObjects method will
                automatically be implemented on the object, returning
                all objects which have this one's path as a prefix of
                theirs. Note that the InterfacesAdded and
                InterfacesRemoved signals will not be automatically
                emitted.
NwbT)r<   serviceObject__init__r   r   r   r   object_manager	_template_template_parametersopenr   is_logfile_ownerr   r   _reset)r   r   r   r   r   r   r   r   s   &&&&&&&&r   r   DBusMockObject.__init__   s    : 	$$TT: 	"!28<(,9=! /6tGT*4 $+-"=EEr   c                   < V ^8  d   QhRR/# r   rq   NrP   )r   r   s   "r   r   r      s       r   c                     V P                   '       d1   V P                  '       d   V P                   P                  4        R # R # R #   \         d     R # i ; iN)r   r   closeAttributeErrorr   s   &r   __del__DBusMockObject.__del__   sD    	||| 5 5 5""$ !6| 		s   A A A AAc                   < V ^8  d   QhRR/# r   rP   )r   r   s   "r   r   r      s     # # #r   c                    V P                   R8X  d   RMRV P                    R2pRV R2pV P                  \        RRR	V4       W n        R
# )z1Set up this mock object as a D-Bus ObjectManager./zk != '/'zk.startswith('z/')zGret = {dbus.ObjectPath(k): objects[k].props for k in objects.keys() if z }GetManagedObjectsrN   za{oa{sa{sv}}}N)r   	AddMethodOBJECT_MANAGER_IFACEr   )r   condcodes   &  r   _set_up_object_manager%DBusMockObject._set_up_object_manager   sO    !YY#-z^DII;c3RYZ^Y__bc+-@"oW[\"r   c                $   < V ^8  d   QhRS[ RR/# )r   r   rq   N)r   )r   r   s   "r   r   r     s     * *I *$ *r   c                    V P                   V/V n        V P                   / /V n        V P                  '       d   V P	                  4        R # R # r   )r   r   methodsr   r   )r   r   s   &&r   r   DBusMockObject._reset  sA    nne,
 ;?.."9M!!!'') "r   ssrK   )r   out_signaturec                ,   < V ^8  d   QhRS[ RS[ RS[/# )r   interface_nameproperty_namerq   r   r   )r   r   s   "r   r   r     s"      # c c r   c                >   V P                  RV P                   RV RV 24       V'       g   V P                  p V P                  V4      V,          #   \         d@   p\
        P                  P                  RT,           T P                  R,           R7      ThRp?ii ; i)z/Standard D-Bus API for getting a property valuezGet rO   .no such property .UnknownPropertyrs   N)r   r   r   GetAllKeyErrorr<   ri   rj   )r   r   r   r|   s   &&& r   GetDBusMockObject.Get  s     	4		{!N#31]ODE!^^N	;;~.}== 	////#m3$..K]:] 0 	s   A B:BBrR   za{sv}c                &   < V ^8  d   QhRS[ RS[/# )r   r   rq   r   r   )r   r   s   "r   r   r      s      S y r   c                .   V P                  RV P                   RV 24       V'       g   V P                  p V P                  V,          #   \         d@   p\
        P                  P                  RT,           T P                  R,           R7      ThRp?ii ; i)z2Standard D-Bus API for getting all property valueszGetAll rO   no such interface .UnknownInterfacers   N)r   r   r   r   r   r<   ri   rj   )r   r   ___r|   s   &&*, r   r   DBusMockObject.GetAll  s     	7499+Q~&678!^^N	::n-- 	////$~5DNNM`<` 0 	s   A
 
B:BBssvrN   c                0   < V ^8  d   QhRS[ RS[ RS[RR/# )r   r   r   rk   rq   Nr   )r   r   s   "r   r   r   /  s*     
 
# 
c 
# 
TX 
r   c                6   V P                  RV P                   RV RV \        V34       24        V P                  V,          pY&9  d:   \
        P                  P                  RT,           T P                  R	,           R7      hY6T&   T P                  R
RRT\
        P                  ! Y#/RR7      \
        P                  ! . RR7      .4       R#   \         d@   p\
        P                  P                  RT,           T P                  R,           R7      ThRp?ii ; i)z/Standard D-Bus API for setting a property valuezSet rO   r   r   r   rs   Nr   r   zorg.freedesktop.DBus.PropertiesPropertiesChangedsa{sv}assvrp   rR   )r   r   rS   r   r   r<   ri   rj   r   
EmitSignalrf   rd   )r   r   r   rk   r   r   iface_propsr|   s   &&&&*,  r   SetDBusMockObject.Set.  s    	4		{!N#31]OLRWQYDZC[\]	**^4K +////#m3$..K]:] 0   &+M"-T__m-CtTVZV`V`acorVst		
  	////$~5DNNM`<` 0 	s   C D:DDzssa{sv}a(ssss)c          
      F   < V ^8  d   QhRS[ RS[ RS[RS[S[,          RR/# )r   r   r   
propertiesr   rq   N)r   r   r   
MethodType)r   r   s   "r   r   r   J  sA     F FF$'F5>FIMjIYF	Fr   c                d   V\         9   d&   \        P                  P                  RV R2RR7      hVP	                  R\
        4      pVP	                  R4      pV! V P                  WW7R7      pV P                  Vn        V P                  Vn        RVn	        VP                  W$4       V\         V&   R	# )
u]  Dynamically add a new D-Bus object to the mock

:param path: D-Bus object path
:param interface: Primary D-Bus interface name of this object (where
           properties and methods will be put on)
:param properties: A property_name (string) → value map with initial
            properties on "interface"
:param methods: An array of 4-tuples (name, in_sig, out_sig, code) describing
         methods to add to "interface"; see AddMethod() for details of
         the tuple values

Keyword Arguments:
:param mock_class: A DBusMockObject derived class name (this is only possible
      when the method is not called via dbus)
:param mock_data: Additional data which will be passed to the DBusMockObject
      constructor

If this is a D-Bus ObjectManager instance, the InterfacesAdded signal
will *not* be emitted for the object automatically; it must be emitted
manually if desired. This is because AddInterface may be called after
AddObject, but before the InterfacesAdded signal should be emitted.

Example::

    dbus_proxy.AddObject('/com/example/Foo/Manager',
                         'com.example.Foo.Control',
                         {
                             'state': dbus.String('online'),
                         },
                         [
                             ('Start', '', '', ''),
                             ('EchoInt', 'i', 'i', 'ret = args[0]'),
                             ('GetClients', '', 'ao', 'ret = ["/com/example/Foo/Client1"]'),
                         ])

Example 2 (in a template)::

    class FooManager(dbusmock.mockobject.DBusMockObject):
        def __init__(self, *args, **kwargs):
            super(FooManager, self).__init__(*args, **kwargs)
            self.magic = kwargs.get('mock_data')

        @dbus.service.method('com.example.Foo.Control', in_signature='i', out_signature='i')
        def EchoMagic(self, input):
            return self.magic + input

    dbus_proxy.AddObject('/com/example/Foo/Manager',
                         'com.example.Foo.Control',
                         {}, [],
                         mock_class=FooManager,
                         mock_data=42)
object  already exists#org.freedesktop.DBus.Mock.NameErrorrs   
mock_classr   )r   FN)objectsr<   ri   rj   r+   r   r   r   r   r   
AddMethods)	r   r   r   r   r   r   r   r   objs	   &&&&&,   r   	AddObjectDBusMockObject.AddObjectI  s    p 7?////$/6[ 0   ZZn=
JJ{+	Yll!00$y*r   c                $   < V ^8  d   QhRS[ RR/# r   r   rq   Nr!   )r   r   s   "r   r   r     s        r   c                     \         V,          P                  4        \         V R#   \         d,   p\        P                  P                  RT R2RR7      ThRp?ii ; i)zRemove a D-Bus object from the mock

As with AddObject, this will *not* emit the InterfacesRemoved signal if
it's an ObjectManager instance.
r   z does not existr   rs   N)r   remove_from_connectionr   r<   ri   rj   )r   r   r|   s   && r   RemoveObjectDBusMockObject.RemoveObject  s\    	DM002 	////$/6[ 0 	s   "& A&AAc                   < V ^8  d   QhRR/# r   rP   )r   r   s   "r   r   r     s     " "t "r   c                   \         P                  4        F'  w  rWP                  8w  g   K  VP                  4        K)  	  \         P	                  4        V P
                  V P                  ,           F  p \        V P                  V4       K  	  V P                  / 4       V P                  e'   V P                  V P                  V P                  4       V \         V P                  &   R#   \         d     K  i ; i)aE  Reset the mock object state.

Remove all mock objects from the bus and tidy up so the state is as if
python-dbusmock had just been restarted. If the mock object was
originally created with a template (from the command line, the Python
API or by calling AddTemplate over D-Bus), it will be
re-instantiated with that template.
N)r   rD   r   r   clearr   r   delattr	__class__r   r   r   AddTemplater   )r   obj_namer   method_names   &   r   ResetDBusMockObject.Reset  s     %]]_MH99$**, - 	
  <<77K4 8 	B>>%T^^T-F-FG!		 " s   5C))C87C8sssssc          
      6   < V ^8  d   QhRS[ RS[ RS[ RS[ RR/# )r   r    in_sigout_sigr   rq   Nr!   )r   r   s   "r   r   r     s?     Ba Ba Bac BaC Bas BaW[ Bar   c                  aaa S'       g   V P                   o\        \        P                  ! S4      4      pVVV3R lp\        P                  P                  SVR7      ! V4      p\        S4      Vn        SVn        \        ^V^,           4       U	u. uF  p	RV	 2NK
  	  up	Vn
        SV P                   8X  d   \        V P                  SV4       SWEV3V P                  P                  S/ 4      \        S4      &   R# u up	i )a  Dynamically add a method to this object

:param interface: D-Bus interface to add this to. For convenience you can
                  specify '' here to add the method to the object's main
                  interface (as specified on construction).
:param name: Name of the method
:param in_sig: Signature of input arguments; for example "ias" for a method
               that takes an int32 and a string array as arguments; see
               `the DBus spec <http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures>`_.
:param out_sig: Signature of output arguments; for example "s" for a method
               that returns a string; use '' for methods that do not return
               anything.
:param code: Python 3 code to run in the method call; you have access to the
             arguments through the "args" list, and can set the return value
             by assigning a value to the "ret" variable. You can also read the
             global "objects" variable, which is a dictionary mapping object
             paths to DBusMockObject instances.

             For keeping state across method calls, you are free to use normal
             Python members of the "self" object, which will be persistent for
             the whole mock's life time. E. g. you can have a method with
             "self.my_state = True", and another method that returns it with
             "ret = self.my_state".

             Methods can raise exceptions in the usual way, in particular
             `dbus.exceptions.DBusException <https://dbus.freedesktop.org/doc/dbus-python/dbus.html#dbus.DBusException>`_.

             When specifying '', the method will not do anything (except
             logging) and return None.


This is meant for adding a method to a mock at runtime, from any programming language.
You can also use it in templates in the load() function.

For implementing non-trivial and static methods in templates, it is recommended to
implement them in the normal dbus-python way with using the @dbus.service.method
decorator instead.
c                 >   < \         P                  ! V SSS.VO5/ VB # r   )r   mock_method)r   rQ   r   r  r   r    s   &*,r   <lambda>*DBusMockObject.AddMethod.<locals>.<lambda>  s)    ~/I/I)T60
,00
4:0
r   )r   argN)r   rt   r<   r]   r   methodr   r   r   range
_dbus_argssetattrr   r   
setdefault)
r   r   r    r  r  r   n_argsr
  dbus_methodis
   &fff&&    r   r   DBusMockObject.AddMethod  s    T IT^^F+,
 ll)))7)KFS"4y)/&5:1fqj5I!J5ICs)5I!J &DNND+6=CWT_<`	2.s4y9 "Ks   C=zsa(ssss)c                :   < V ^8  d   QhRS[ RS[S[,          RR/# )r   r   r   rq   N)r   r   r   )r   r   s   "r   r   r     s'     
/ 
/C 
/$z2B 
/t 
/r   c                @    V F  pV P                   ! V.VO5!   K  	  R# )a  Add several methods to this object

:param interface: D-Bus interface to add this to. For convenience you can
                  specify '' here to add the method to the object's main
                  interface (as specified on construction).
:param methods: list of 4-tuples (name, in_sig, out_sig, code) describing one
                method each. See AddMethod() for details of the tuple values.
N)r   )r   r   r   r
  s   &&& r   r   DBusMockObject.AddMethods  s     FNN9.v. r   c                    \        V\        P                  \        P                  34      '       g   \        P                  ! V4      pW0P
                  P                  V/ 4      V&   R # r   )r;   r<   rf   rd   copyr   r  r   r   r    rk   s   &&&&r   _set_propertyDBusMockObject._set_property  sE     %$//4::!>??IIe$E5:

i,T2r   zsa{sv}c                *   < V ^8  d   QhRS[ RS[RR/# r   r   r   rq   Nr   )r   r   s   "r   r   r     s'     p p# p9 p pr   c                   / pVP                  4        F  w  rEV'       g   V P                  pW@P                  P                  V/ 4      9  d-   \        P
                  P                  RV R2VR,           R7      hV P                  WV4       \        V4      W4&   K  	  V P                  \        P                  RRW. .4       R# )uT  Update properties on this object and send a PropertiesChanged signal

:param interface: D-Bus interface to update this to. For convenience you can
                  specify '' here to add the property to the object's main
                  interface (as specified on construction).
:param properties: A property_name (string) → value map
	property z
 not foundz.NoSuchPropertyrs   r   r   N)rD   r   r   r+   r<   ri   rj   r  rn   r   PROPERTIES_IFACE)r   r   r   changed_propsr    rk   s   &&&   r   UpdatePropertiesDBusMockObject.UpdateProperties  s     %++-KD NN	::>>)R88oo33ivZ4PW`ctWt3uuy6"7">M . 	--/BJQZkmPnor   c                0   < V ^8  d   QhRS[ RS[ RS[RR/# )r   r   r    rk   rq   Nr   )r   r   s   "r   r   r   3  s)     3 3S 3 3C 3D 3r   c                    V'       g   V P                   pW P                  P                  V/ 4      9   d7   \        P                  P                  RV R2V P                   R,           R7      hV P                  WV4       R# )a*  Add property to this object

:param interface: D-Bus interface to add this to. For convenience you can
                   specify '' here to add the property to the object's main
                   interface (as specified on construction).
:param name: Property name.
:param value: Property value.
r  r   z.PropertyExistsrs   N)r   r   r+   r<   ri   rj   r  r  s   &&&&r   AddPropertyDBusMockObject.AddProperty2  sk     I::>>)R00////D61IZ8Z 0   	9E2r   c                *   < V ^8  d   QhRS[ RS[RR/# r  r   )r   r   s   "r   r   r   F  s"     	. 	.s 	.	 	.d 	.r   c                \    VP                  4        F  w  r4V P                  WV4       K  	  R# )u2  Add several properties to this object

:param interface: D-Bus interface to add this to. For convenience you can
                  specify '' here to add the property to the object's main
                  interface (as specified on construction).
:param properties: A property_name (string) → value map
N)rD   r%  )r   r   r   rJ   rK   s   &&&  r   AddPropertiesDBusMockObject.AddPropertiesE  s)     $$&DAY1- 'r   c                *   < V ^8  d   QhRS[ RS[RR/# )r   template
parametersrq   Nr   )r   r   s   "r   r   r   R  s"     5/ 5/C 5/Y 5/4 5/r   c                    \        V4      p\        TR4      '       d#   TP                  '       d   T P                  4        \        T4       F  p\        Y54      pR\        T4      9   g   K   R\        T4      9  g   TP                  '       d   KD  \        Y4      p\        T P                  YV4       TP                  TP                  R	T3T P                   P#                  TP$                  / 4      \'        T4      &   K  	  Tf   / pTP)                  Y4       Yn        Y n        R#   \         d/   p\        P                  P	                  RT RT: 2RR7      ThRp?ii ; i)
u  Load a template into the mock.

python-dbusmock ships a set of standard mocks for common system
services such as UPower and NetworkManager. With these the actual tests
become a lot simpler, as they only have to set up the particular
properties for the tests, and not the skeleton of common properties,
interfaces, and methods.

:param template: Name of the template to load or the full path to a *.py file
                 for custom templates. See "pydoc dbusmock.templates" for a
                 list of available templates from python-dbusmock package, and
                 "pydoc dbusmock.templates.NAME" for documentation about
                 template NAME.
:param parameters: A parameter (string) → value (variant) map, for
                   parameterizing templates. Each template can define their
                   own, see documentation of that particular template for
                   details.
zCannot add template r9   z'org.freedesktop.DBus.Mock.TemplateErrorrs   NIS_OBJECT_MANAGER_dbus_interface_dbus_is_signalrN   )r2   ImportErrorr<   ri   rj   hasattrr/  r   dirr   r1  r   r  r   r   _dbus_out_signaturer   r  r0  r   loadr   r   )r   r,  r-  moduler|   symbolfns   &&&    r   r   DBusMockObject.AddTemplateQ  s;   (	 *F 6.//F4L4L4L'') &kF(B CG+1B#b'1QY[YkYkYk!$+ 3))**	P''(:(:B?FL " JD% "$.!A  	////&xj1%8?h 0 	s   D$ $E/)EEc                P   < V ^8  d   QhRS[ RS[ RS[ RS[S[R3,          RS[RR/# 	r   r   r    rp   sigargs.detailsrq   Nr   r	   r   r   )r   r   s   "r   r   r     sM     H HH$'H47HBGS/H\eH	Hr   c                   V'       g   V P                   p\        W44      pVP                  R V P                  4      p\        P
                  P                  WqV4      pVP                  ! VRV/  VP                  RR4      p	V	e   VP                  V	4       V P                   F  p
V
^ ,          pVP                  V4       K  	  V P                  RV RV RV \        V4       24       R# )r   rp   destinationNzemit rO   r   )r   r}   r+   r   r<   lowlevelSignalMessagerx   set_destination	locationssend_messager   rS   )r   r   r    rp   r=  r>  rQ   r   sigdestlocationconns   &&&&&&      r   _emit_signalDBusMockObject._emit_signal  s     IY0{{6499-mm))$4@

D.I.{{=$/%HA;Dc" ' 	5a	{!D6,t2D1EFGr   sssavc          
      J   < V ^8  d   QhRS[ RS[ RS[ RS[S[R3,          RR/# )r   r   r    rp   r=  .rq   N)r   r	   r   )r   r   s   "r   r   r     sC     C CC Cs Cs CUSVX[S[_ Cae Cr   c                ,    V P                  WW4/ 4       R# )a  Emit a signal from the object.

:param interface: D-Bus interface to send the signal from. For convenience you
                  can specify '' here to add the method to the object's main
                  interface (as specified on construction).
:param name: Name of the signal
:param signature: Signature of input arguments; for example "ias" for a signal
                  that takes an int32 and a string array as arguments; see
                  http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures
:param args: variant array with signal arguments; must match order and type in
             "signature"
NrK  )r   r   r    rp   r=  s   &&&&&r   r   DBusMockObject.EmitSignal  s     	)9rBr   z
sssava{sv}c                P   < V ^8  d   QhRS[ RS[ RS[ RS[S[R3,          RS[RR/# r<  r?  )r   r   s   "r   r   r     sM     H HH$'H47HBGS/H\eH	Hr   c                ,    V P                  WW4V4       R# )aQ  Emit a signal from the object with extra details.

:param interface: D-Bus interface to send the signal from. For convenience you
                  can specify '' here to add the method to the object's main
                  interface (as specified on construction).
:param name: Name of the signal
:param signature: Signature of input arguments; for example "ias" for a signal
               that takes an int32 and a string array as arguments; see
               http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures
:param args: variant array with signal arguments; must match order and type in
             "signature"
:param details: dictionary with a string key/value entries. Supported keys are:
           "destination": for the signal destination
           "path": for the object path to send the signal from
NrP  )r   r   r    rp   r=  r>  s   &&&&&&r   EmitSignalDetailed!DBusMockObject.EmitSignalDetailed  s    & 	)9wGr   za(tsav)c                0   < V ^8  d   QhRS[ S[,          /# r   rq   )r   CallLogType)r   r   s   "r   r   r     s      ${+ r   c                    V P                   # )z}List all the logged calls since the last call to ClearCalls().

Return a list of (timestamp, method_name, args_list) tuples.
r   r   s   &r   GetCallsDBusMockObject.GetCalls  s     }}r   za(tav)c                \   < V ^8  d   QhRS[ RS[S[S[S[S[,          3,          ,          /# )r   r
  rq   )r   r   r	   r@   r   r   )r   r   s   "r   r   r     s2     O OS OT%Xc]8J2K-L Or   c                    V P                    Uu. uF$  q"^,          V8X  g   K  V^ ,          V^,          3NK&  	  up# u upi )zcList all the logged calls of a particular method.

Return a list of (timestamp, args_list) tuples.
rZ  )r   r
  rows   && r   GetMethodCallsDBusMockObject.GetMethodCalls  s9     -1MMNMSVv=M QQ MNNNs   <<c                   < V ^8  d   QhRR/# r   rP   )r   r   s   "r   r   r     s      D r   c                    . V n         R# )z&Empty the log of mock call signatures.NrZ  r   s   &r   
ClearCallsDBusMockObject.ClearCalls  s     r   savr   c                    R# )zSignal emitted for every called mock method.

This is emitted for all mock method calls.  This can be used to confirm
that a particular method was called with particular arguments, as an
alternative to reading the mock's log or GetCalls().
NrP   )r   r    rQ   s   &&&r   r   DBusMockObject.MethodCalled  s    r   c                $   < V ^8  d   QhRS[ RR/# r   r!   )r   r   s   "r   r   r     s      c d r   c                    V P                   eP   V P                   P                  \        RR\        P                  ! V4      \
        V,          P                  .4       R# R# )z)Emit ObjectManager.InterfacesAdded signalNInterfacesAddedz
oa{sa{sv}}r   r   r   r<   rZ   r   r   r   r   s   &&r   object_manager_emit_added(DBusMockObject.object_manager_emit_added  sO     ***$&7X\H]_fgk_l_r_rGs +r   c                $   < V ^8  d   QhRS[ RR/# r   r!   )r   r   s   "r   r   r     s        r   c                    V P                   eP   V P                   P                  \        RR\        P                  ! V4      \
        V,          P                  .4       R# R# )z+Emit ObjectManager.InterfacesRemoved signalNInterfacesRemovedoasrl  rm  s   &&r   object_manager_emit_removed*DBusMockObject.object_manager_emit_removed  sO     ***$&954??SWCXZabfZgZmZmBn +r   c                2   < V ^8  d   QhRS[ RS[ RS[ RS[/# )r   r   r  r   rq   r   )r   r   s   "r   r   r     s*      S s # `c r   c                    \        W44      pV P                  V\        V4      ,           4       V P                  P	                  \        \        P                  ! 4       4      \        V4      V34       V P                  W&4       V P                  V,          V,          ^,          pV'       d+   \        V\        P                  4      '       d   V! V .VO5!  # V'       d>   \        4       P                  4       p\        V\!        4       V4       RV9   d
   VR,          # R#   \"         d0   p	T P                  TR,           \        T	4      ,           4       T	hRp	?	ii ; i)zMaster mock method.

This gets "instantiated" in AddMethod(). Execute the code snippet of
the method and return the "ret" variable if it was set.
retz	 raised: N)r}   r   rS   r   rx   r@   r   r   r   r   r;   rW   FunctionTypelocalsr  r   globalsrz   )
r   r   r  r   m_argsr   rQ   r   locr|   s
   &&&&*,    r   r  DBusMockObject.mock_method  s   	 6DHH[<#556MM  #diik"2C4Dd!KLk0
 <<	*;7:D
4););<<D(4((hmmoT79c*C<u:%
 	  	HH[;.Q78G	s$   CD D <D E'*EEc                $   < V ^8  d   QhRS[ RR/# )r   msgrq   Nr!   )r   r   s   "r   r   r     s     < <s <t <r   c                   V P                   '       d   V P                   P                  4       M\        P                  P                  4       p\        P
                  ! V\        P                  ! 4       R RV R2P                  4       4       R# )zLog a message, prefixed with a timestamp.

If a log file was specified in the constructor, it is written there,
otherwise it goes to stdout.
z.3frO   
N)r   filenosysstdoutr)   writer   encode)r   r  fds   && r   r   DBusMockObject.log  sZ     '+lllT\\  "

8I8I8K
		C(#b188:;r   object_pathrv   )r   r   path_keywordconnection_keywordc                T   < V ^8  d   QhRS[ RS[P                  P                  RS[ /# )r   r  rv   rq   )r   r<   rv   
Connection)r   r   s   "r   r   r   #  s-     5 5c 5t7Q7Q 5VY 5r   c                *   V P                   P                  R,           V P                   P                  ,           pV P                  V,          pVP	                  4       pV P
                  P                  4        F:  w  rgVP                  4        F!  w  rV	^,          VP                  V/ 4      V&   K#  	  K<  	  WPP                  V&   \        P                  P                  P                  WV4      p
\        P                  ! V
4      pV P                  P                  4        F  w  rVP                  RV R24      pVf+   \        P                   ! RRV/4      pVP#                  V4       VP                  4        Fa  w  ppVf   K  \        P                   ! RRVR\        P$                  P&                  P)                  V4      RR	/4      pVP#                  V4       Kc  	  K  	  \        P*                  ! VR
RR7      P-                  R
4      p
W@P                  V&   V
# )zReturn XML description of this object's interfaces, methods and signals.

This wraps dbus-python's Introspect() method to include the dynamic
methods and properties.
r   z.//interface[@name='z']r   r    propertyrg   access	readwriteutf8xml)encodingr
  )r   
__module__r   _dbus_class_tabler  r   rD   r  r<   r   r   
IntrospectET
fromstringr   findElementrx   rB  Messageguess_signaturetostringdecode)r   r  rv   clsorig_interfacesmock_interfacesifacer   r
  implr  treer    
name_propsr   propvalelems   &&&               r   r  DBusMockObject.Introspect  s   " nn''#-0G0GG005)..0"ll002NE '@DQ**5"5f= !0 3 '6s#ll!!,,T
K}}S! $

 0 0 2D 		$8b"ABI JJ{VTNC	I&'--/	c;zz 5 5 E Ec J +	   & 0 !32 kk$>EEfM '6s#
r   )r   r   r   r   r   r   r   r   r   r   r   r   r   )NFN)+r   r  __qualname____firstlineno____doc__r   r   r   r   r<   r   r
  r  r   r   r   
MOCK_IFACEr   r   r   r   r   r  r!  r%  r)  r   rK  r   rT  r[  r`  rd  signalr   rn  rt  r  r   INTROSPECTABLE_IFACEr  __static_attributes____classdictcell__)r   s   @r   r   r      s    1 1f # #* * 
\\..TQTU V 
\\..SPWX Y 
\\..URTU
 V
4 
\\2BRTUF VFP 
\\#RH I 
\\"BG" H"> 
\\'LBa MBaH 
\\*BO
/ P
/; 
\\("Mp Np* 
\\%rJ3 K3$ 
\\("M	. N	. 
\\("M5/ N5/nH H* 
\\'LC MC 
\\,bQH RH( 
\\"IN O 
\\#XNO OO 
\\"BG H
 
\\u5 6   @< < 
\\!!"'  55r   r   c                      V P                   T;'       g    V P                  ,          V,          pV^,          V^,          3#   \         d    \        YT4      u # i ; i)   )r   r   r   orig_method_lookup)r   r   dbus_interfacer{   s   &&& r   _dbusmock_method_lookupr  `  sW    DKK77#--8E!ad| D!#NCCDs   A +A AAc                :    V ^8  d   QhR\         \        ,          /# rW  )r   r   )r   s   "r   r   r   p  s      Xc] r   c                 *    \         P                  4       # )z Return all existing object paths)r   keysrP   r   r   get_objectsr  p  s     <<>r   c                $    V ^8  d   QhR\         /# rW  )r   )r   s   "r   r   r   v  s       r   c                    \         V ,          # )z%Return object for a given object path)r   )r   s   &r   
get_objectr  v  s     4=r   c                Z    V ^8  d   Qh/ ^ \         9   d   \        \        R3,          ;R&   # )r   r   r   )__conditional_annotations__r   r   )r   s   "r   r   r      s'     ) )B * )c##	$ )C *r   )2r  r  
__author____copyright__r  r   r   importlib.utilr)   r  r   rW   pathlibr   typingr   r   r   r   r   r   r	   	xml.etreer
   r  r<   dbus.servicer   r  r   r   r   r   r@   rX  r   r2   rS   rn   r}   r   r   r   r   _method_lookupr  r  r  r  r   )r  s   @r   <module>r     s   ) 

     	 
    G G G '    (* )(
;  cN	3S#%&
Chsm+,A,!HNB$(_
T\\(( _
H \\00 D 6 r   