| 1 |
# SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
|
| 3 |
""" |
| 4 |
DBus module |
| 5 |
|
| 6 |
Has an endpoint decorator to wrap a method for DBus |
| 7 |
""" |
| 8 |
from functools import wraps |
| 9 |
|
| 10 |
|
| 11 |
def endpoint(interface_name, function_name, in_sig=None, out_sig=None, byte_arrays=False): |
| 12 |
""" |
| 13 |
DBus Endpoint |
| 14 |
|
| 15 |
:param interface_name: DBus Interface name |
| 16 |
:type interface_name: str |
| 17 |
|
| 18 |
:param function_name: DBus Method name |
| 19 |
:type function_name: str |
| 20 |
|
| 21 |
:param in_sig: DBus parameter signature |
| 22 |
:type in_sig: str |
| 23 |
|
| 24 |
:param out_sig: DBus return signature |
| 25 |
:type out_sig: str |
| 26 |
|
| 27 |
:param byte_arrays: is Byte Array |
| 28 |
:type byte_arrays: bool |
| 29 |
|
| 30 |
:return: Function |
| 31 |
:rtype: callable |
| 32 |
""" |
| 33 |
# pylint: disable=missing-docstring |
| 34 |
def inner_render(func): |
| 35 |
def wrapped(*args, **kwargs): |
| 36 |
return func(*args, **kwargs) |
| 37 |
wrapped.endpoint = True |
| 38 |
wrapped.interface = interface_name |
| 39 |
wrapped.name = function_name |
| 40 |
wrapped.in_sig = in_sig |
| 41 |
wrapped.out_sig = out_sig |
| 42 |
wrapped.byte_arrays = byte_arrays |
| 43 |
wrapped.code = func.__code__ |
| 44 |
wrapped.globals = func.__globals__ |
| 45 |
wrapped.defaults = func.__defaults__ |
| 46 |
wrapped.closure = func.__closure__ |
| 47 |
return wraps(func)(wrapped) |
| 48 |
return inner_render |