~jderose/ubuntu/precise/dbus-python/oneiric-backport

« back to all changes in this revision

Viewing changes to dbus/decorators.py

  • Committer: Package Import Robot
  • Author(s): Barry Warsaw
  • Date: 2012-01-12 14:47:33 UTC
  • Revision ID: package-import@ubuntu.com-20120112144733-xtfbmgw30h0j40d2
Tags: 0.84.0-2ubuntu1
* debian/patches:
  - since-0.84.0.patch: Upstream unreleased changes from git tag
    dbus-python-0.84.0 to HEAD.  This is a precursor to the following.
  - python3-support.patch: Upstream unreleased changes from git
    `python3` branch for supporting Python 3. (LP: #893091)
* debian/rules: Enable the test suite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from dbus import validate_interface_name, Signature, validate_member_name
34
34
from dbus.lowlevel import SignalMessage
35
35
from dbus.exceptions import DBusException
 
36
from dbus._compat import is_py2
36
37
 
37
38
 
38
39
def method(dbus_interface, in_signature=None, out_signature=None,
39
 
        async_callbacks=None,
40
 
        sender_keyword=None, path_keyword=None, destination_keyword=None,
41
 
        message_keyword=None, connection_keyword=None,
42
 
        utf8_strings=False, byte_arrays=False,
43
 
        rel_path_keyword=None):
 
40
           async_callbacks=None,
 
41
           sender_keyword=None, path_keyword=None, destination_keyword=None,
 
42
           message_keyword=None, connection_keyword=None,
 
43
           byte_arrays=False,
 
44
           rel_path_keyword=None, **kwargs):
44
45
    """Factory for decorators used to mark methods of a `dbus.service.Object`
45
46
    to be exported on the D-Bus.
46
47
 
182
183
            in_sig = tuple(Signature(in_signature))
183
184
 
184
185
            if len(in_sig) > len(args):
185
 
                raise ValueError, 'input signature is longer than the number of arguments taken'
 
186
                raise ValueError('input signature is longer than the number of arguments taken')
186
187
            elif len(in_sig) < len(args):
187
 
                raise ValueError, 'input signature is shorter than the number of arguments taken'
 
188
                raise ValueError('input signature is shorter than the number of arguments taken')
188
189
 
189
190
        func._dbus_is_method = True
190
191
        func._dbus_async_callbacks = async_callbacks
198
199
        func._dbus_message_keyword = message_keyword
199
200
        func._dbus_connection_keyword = connection_keyword
200
201
        func._dbus_args = args
201
 
        func._dbus_get_args_options = {'byte_arrays': byte_arrays,
202
 
                                       'utf8_strings': utf8_strings}
 
202
        func._dbus_get_args_options = dict(byte_arrays=byte_arrays)
 
203
        if is_py2:
 
204
            func._dbus_get_args_options['utf8_strings'] = kwargs.get(
 
205
                'utf8_strings', False)
 
206
        elif 'utf8_strings' in kwargs:
 
207
            raise TypeError("unexpected keyword argument 'utf8_strings'")
203
208
        return func
204
209
 
205
210
    return decorator
325
330
            sig = tuple(Signature(signature))
326
331
 
327
332
            if len(sig) > len(args):
328
 
                raise ValueError, 'signal signature is longer than the number of arguments provided'
 
333
                raise ValueError('signal signature is longer than the number of arguments provided')
329
334
            elif len(sig) < len(args):
330
 
                raise ValueError, 'signal signature is shorter than the number of arguments provided'
 
335
                raise ValueError('signal signature is shorter than the number of arguments provided')
331
336
 
332
337
        emit_signal.__name__ = func.__name__
333
338
        emit_signal.__doc__ = func.__doc__