Mercurial > libervia-backend
comparison libervia/backend/bridge/bridge_constructor/constructors/dbus/constructor.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
25 CORE_TEMPLATE = "dbus_core_template.py" | 25 CORE_TEMPLATE = "dbus_core_template.py" |
26 CORE_DEST = "dbus_bridge.py" | 26 CORE_DEST = "dbus_bridge.py" |
27 CORE_FORMATS = { | 27 CORE_FORMATS = { |
28 "methods_declarations": """\ | 28 "methods_declarations": """\ |
29 Method('{name}', arguments='{sig_in}', returns='{sig_out}'),""", | 29 Method('{name}', arguments='{sig_in}', returns='{sig_out}'),""", |
30 | |
31 "methods": """\ | 30 "methods": """\ |
32 def dbus_{name}(self, {args}): | 31 def dbus_{name}(self, {args}): |
33 {debug}return self._callback("{name}", {args_no_default})\n""", | 32 {debug}return self._callback("{name}", {args_no_default})\n""", |
34 | |
35 "signals_declarations": """\ | 33 "signals_declarations": """\ |
36 Signal('{name}', '{sig_in}'),""", | 34 Signal('{name}', '{sig_in}'),""", |
37 | |
38 "signals": """\ | 35 "signals": """\ |
39 def {name}(self, {args}): | 36 def {name}(self, {args}): |
40 self._obj.emitSignal("{name}", {args})\n""", | 37 self._obj.emitSignal("{name}", {args})\n""", |
41 } | 38 } |
42 | 39 |
66 | 63 |
67 def core_completion_method(self, completion, function, default, arg_doc, async_): | 64 def core_completion_method(self, completion, function, default, arg_doc, async_): |
68 completion.update( | 65 completion.update( |
69 { | 66 { |
70 "debug": ( | 67 "debug": ( |
71 "" if not self.args.debug | 68 "" |
69 if not self.args.debug | |
72 else f'log.debug ("{completion["name"]}")\n{8 * " "}' | 70 else f'log.debug ("{completion["name"]}")\n{8 * " "}' |
73 ) | 71 ) |
74 } | 72 } |
75 ) | 73 ) |
76 | 74 |
77 def frontend_completion_method(self, completion, function, default, arg_doc, async_): | 75 def frontend_completion_method(self, completion, function, default, arg_doc, async_): |
78 completion.update( | 76 completion.update( |
79 { | 77 { |
80 # XXX: we can manage blocking call in the same way as async one: if callback is None the call will be blocking | 78 # XXX: we can manage blocking call in the same way as async one: if callback is None the call will be blocking |
81 "debug": "" | 79 "debug": ( |
82 if not self.args.debug | 80 "" |
83 else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "), | 81 if not self.args.debug |
82 else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " ") | |
83 ), | |
84 "args_result": self.get_arguments(function["sig_in"], name=arg_doc), | 84 "args_result": self.get_arguments(function["sig_in"], name=arg_doc), |
85 "async_args": "callback=None, errback=None", | 85 "async_args": "callback=None, errback=None", |
86 "async_comma": ", " if function["sig_in"] else "", | 86 "async_comma": ", " if function["sig_in"] else "", |
87 "error_handler": """if callback is None: | 87 "error_handler": """if callback is None: |
88 error_handler = None | 88 error_handler = None |
93 """, | 93 """, |
94 } | 94 } |
95 ) | 95 ) |
96 if async_: | 96 if async_: |
97 completion["blocking_call"] = "" | 97 completion["blocking_call"] = "" |
98 completion[ | 98 completion["async_args_result"] = ( |
99 "async_args_result" | 99 "timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler" |
100 ] = "timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler" | 100 ) |
101 else: | 101 else: |
102 # XXX: To have a blocking call, we must have not reply_handler, so we test if callback exists, and add reply_handler only in this case | 102 # XXX: To have a blocking call, we must have not reply_handler, so we test if callback exists, and add reply_handler only in this case |
103 completion[ | 103 completion[ |
104 "blocking_call" | 104 "blocking_call" |
105 ] = """kwargs={} | 105 ] = """kwargs={} |