Current File : //proc/3/task/3/cwd/proc/self/root/usr/lib64/python2.7/site-packages/dbus/decorators.pyc
�
毖Sc@s�dZdZdZddlZddlmZmZmZddlm Z ddl
mZdd lm
Z
ddddddddedd
�
Zdddd�ZdS(
sService-side D-Bus decorators.tmethodtsignaltrestructuredtexti����N(tvalidate_interface_namet Signaturetvalidate_member_name(t
SignalMessage(t
DBusException(tis_py2c
s>t������������ �
�fd�}|S(s�Factory for decorators used to mark methods of a `dbus.service.Object`
to be exported on the D-Bus.
The decorated method will be exported over D-Bus as the method of the
same name on the given D-Bus interface.
:Parameters:
`dbus_interface` : str
Name of a D-Bus interface
`in_signature` : str or None
If not None, the signature of the method parameters in the usual
D-Bus notation
`out_signature` : str or None
If not None, the signature of the return value in the usual
D-Bus notation
`async_callbacks` : tuple containing (str,str), or None
If None (default) the decorated method is expected to return
values matching the `out_signature` as usual, or raise
an exception on error. If not None, the following applies:
`async_callbacks` contains the names of two keyword arguments to
the decorated function, which will be used to provide a success
callback and an error callback (in that order).
When the decorated method is called via the D-Bus, its normal
return value will be ignored; instead, a pair of callbacks are
passed as keyword arguments, and the decorated method is
expected to arrange for one of them to be called.
On success the success callback must be called, passing the
results of this method as positional parameters in the format
given by the `out_signature`.
On error the decorated method may either raise an exception
before it returns, or arrange for the error callback to be
called with an Exception instance as parameter.
`sender_keyword` : str or None
If not None, contains the name of a keyword argument to the
decorated function, conventionally ``'sender'``. When the
method is called, the sender's unique name will be passed as
this keyword argument.
`path_keyword` : str or None
If not None (the default), the decorated method will receive
the destination object path as a keyword argument with this
name. Normally you already know the object path, but in the
case of "fallback paths" you'll usually want to use the object
path in the method's implementation.
For fallback objects, `rel_path_keyword` (new in 0.82.2) is
likely to be more useful.
:Since: 0.80.0?
`rel_path_keyword` : str or None
If not None (the default), the decorated method will receive
the destination object path, relative to the path at which the
object was exported, as a keyword argument with this
name. For non-fallback objects the relative path will always be
'/'.
:Since: 0.82.2
`destination_keyword` : str or None
If not None (the default), the decorated method will receive
the destination bus name as a keyword argument with this name.
Included for completeness - you shouldn't need this.
:Since: 0.80.0?
`message_keyword` : str or None
If not None (the default), the decorated method will receive
the `dbus.lowlevel.MethodCallMessage` as a keyword argument
with this name.
:Since: 0.80.0?
`connection_keyword` : str or None
If not None (the default), the decorated method will receive
the `dbus.connection.Connection` as a keyword argument
with this name. This is generally only useful for objects
that are available on more than one connection.
:Since: 0.82.0
`utf8_strings` : bool
If False (default), D-Bus strings are passed to the decorated
method as objects of class dbus.String, a unicode subclass.
If True, D-Bus strings are passed to the decorated method
as objects of class dbus.UTF8String, a str subclass guaranteed
to be encoded in UTF-8.
This option does not affect object-paths and signatures, which
are always 8-bit strings (str subclass) encoded in ASCII.
:Since: 0.80.0
`byte_arrays` : bool
If False (default), a byte array will be passed to the decorated
method as an `Array` (a list subclass) of `Byte` objects.
If True, a byte array will be passed to the decorated method as
a `ByteArray`, a str subclass. This is usually what you want,
but is switched off by default to keep dbus-python's API
consistent.
:Since: 0.80.0
cs9tj|�d}|jd��r�t��tkrGtd��nt��dkrhtd��n|j�d�|j�d�n�r�|j��n�
r�|j�
�n� r�|j� �n�r�|j��n�r�|j��n�r|j��n�rztt ���}t|�t|�krPtd��qzt|�t|�krztd��qznt
|_�|_�|_
�|_�|_�|_� |_�
|_�|_�|_�|_||_td��|_tr�jdt�|jd<nd�kr5td ��n|S(
Nis\async_callbacks must be a tuple of (keyword for return callback, keyword for error callback)iis<input signature is longer than the number of arguments takens=input signature is shorter than the number of arguments takentbyte_arraystutf8_stringss*unexpected keyword argument 'utf8_strings'(tinspectt
getargspectpopttypettuplet TypeErrortlent
ValueErrortremoveRtTruet_dbus_is_methodt_dbus_async_callbackst_dbus_interfacet_dbus_in_signaturet_dbus_out_signaturet_dbus_sender_keywordt_dbus_path_keywordt_dbus_rel_path_keywordt_dbus_destination_keywordt_dbus_message_keywordt_dbus_connection_keywordt
_dbus_argstdictt_dbus_get_args_optionsRtgettFalse(tfunctargstin_sig(tasync_callbacksR tconnection_keywordtdbus_interfacetdestination_keywordtin_signaturetkwargstmessage_keywordt
out_signaturetpath_keywordtrel_path_keywordtsender_keyword(s5/usr/lib64/python2.7/site-packages/dbus/decorators.pyt decorator�s\
(R(
R*R,R/R(R2R0R+R.R)R R1R-R3((R(R R)R*R+R,R-R.R/R0R1R2s5/usr/lib64/python2.7/site-packages/dbus/decorators.pyR'st
05csyt���dk r]ddlm}|td�tdd��dk r]td��q]n����fd�}|S( s Factory for decorators used to mark methods of a `dbus.service.Object`
to emit signals on the D-Bus.
Whenever the decorated method is called in Python, after the method
body is executed, a signal with the same name as the decorated method,
with the given D-Bus interface, will be emitted from this object.
:Parameters:
`dbus_interface` : str
The D-Bus interface whose signal is emitted
`signature` : str
The signature of the signal in the usual D-Bus notation
`path_keyword` : str or None
A keyword argument to the decorated method. If not None,
that argument will not be emitted as an argument of
the signal, and when the signal is emitted, it will appear
to come from the object path given by the keyword argument.
Note that when calling the decorated method, you must always
pass in the object path as a keyword argument, not as a
positional argument.
This keyword argument cannot be used on objects where
the class attribute ``SUPPORTS_MULTIPLE_OBJECT_PATHS`` is true.
:Deprecated: since 0.82.0. Use `rel_path_keyword` instead.
`rel_path_keyword` : str or None
A keyword argument to the decorated method. If not None,
that argument will not be emitted as an argument of
the signal.
When the signal is emitted, if the named keyword argument is given,
the signal will appear to come from the object path obtained by
appending the keyword argument to the object's object path.
This is useful to implement "fallback objects" (objects which
own an entire subtree of the object-path tree).
If the object is available at more than one object-path on the
same or different connections, the signal will be emitted at
an appropriate object-path on each connection - for instance,
if the object is exported at /abc on connection 1 and at
/def and /x/y/z on connection 2, and the keyword argument is
/foo, then signals will be emitted from /abc/foo and /def/foo
on connection 1, and /x/y/z/foo on connection 2.
:Since: 0.82.0
i����(twarns�dbus.service.signal::path_keyword has been deprecated since dbus-python 0.82.0, and will not work on objects that support multiple object pathst
stacklevelisJdbus.service.signal::path_keyword and rel_path_keyword cannot both be usedcsU�j�t��������fd�}tj��d}|jd�xX��fD]J}|dk r^y|j|�Wq�tk
r�td|��q�Xq^q^W�rtt ���}t
|�t
|�kr�td��qt
|�t
|�krtd��qn�j|_�j|_t|_
�|_�|_||_|S(NcsJd}�dk r}|jr*td��n|j�d�}||jkr}|jj|d�r}td||j��q}nd}�dk r�|j�d�}n�|||�x�|jD]�}|dkr|dks�|dkr�|d}q|d|}n|}t|���}|j d�|�|dj
|�q�WdS( Ns[path_keyword cannot be used on the signals of an object that supports multiple object pathst/sPath %r is not below %rtit signaturei(R6R7(tNonetSUPPORTS_MULTIPLE_OBJECT_PATHSRR
t__dbus_object_path__t
startswithRt locationsRtappendtsend_message(tselfR&tkeywordstabs_pathtrel_pathtlocationtobject_pathtmessage(R*R%tmember_nameR0R1R8(s5/usr/lib64/python2.7/site-packages/dbus/decorators.pytemit_signals0
isfunction has no argument "%s"s@signal signature is longer than the number of arguments providedsAsignal signature is shorter than the number of arguments provided(t__name__RRRR
R9RRRRRt__doc__Rt_dbus_is_signalRt_dbus_signatureR (R%RHR&tkeywordtsig(R*R0R1R8(R%RGs5/usr/lib64/python2.7/site-packages/dbus/decorators.pyR3s0
&
N(RR9twarningsR4tDeprecationWarningR(R*R8R0R1R4R3((R*R0R1R8s5/usr/lib64/python2.7/site-packages/dbus/decorators.pyR�s3
D(smethodssignal(RJt__all__t
__docformat__RtdbusRRRt
dbus.lowlevelRtdbus.exceptionsRtdbus._compatRR9R$RR(((s5/usr/lib64/python2.7/site-packages/dbus/decorators.pyt<module>s �