comparison sat/bridge/bridge_constructor/constructors/pb/constructor.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 378188abe941
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 #-*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 # SàT: a XMPP client 4 # SàT: a XMPP client
5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org)
6 6
7 # This program is free software: you can redistribute it and/or modify 7 # This program is free software: you can redistribute it and/or modify
23 class pbConstructor(base_constructor.Constructor): 23 class pbConstructor(base_constructor.Constructor):
24 NAME = "pb" 24 NAME = "pb"
25 CORE_TEMPLATE = "pb_core_template.py" 25 CORE_TEMPLATE = "pb_core_template.py"
26 CORE_DEST = "pb.py" 26 CORE_DEST = "pb.py"
27 CORE_FORMATS = { 27 CORE_FORMATS = {
28 'signals': """\ 28 "signals": """\
29 def {name}(self, {args}): 29 def {name}(self, {args}):
30 {debug}self.sendSignal("{name}", {args_no_def})\n""", 30 {debug}self.sendSignal("{name}", {args_no_def})\n"""
31 } 31 }
32 32
33 FRONTEND_TEMPLATE = "pb_frontend_template.py" 33 FRONTEND_TEMPLATE = "pb_frontend_template.py"
34 FRONTEND_DEST = CORE_DEST 34 FRONTEND_DEST = CORE_DEST
35 FRONTEND_FORMATS = { 35 FRONTEND_FORMATS = {
36 'methods': """\ 36 "methods": """\
37 def {name}(self{args_comma}{args}, callback=None, errback=None): 37 def {name}(self{args_comma}{args}, callback=None, errback=None):
38 {debug}d = self.root.callRemote("{name}"{args_comma}{args_no_def}) 38 {debug}d = self.root.callRemote("{name}"{args_comma}{args_no_def})
39 if callback is not None: 39 if callback is not None:
40 d.addCallback({callback}) 40 d.addCallback({callback})
41 if errback is None: 41 if errback is None:
42 errback = self._generic_errback 42 errback = self._generic_errback
43 d.addErrback(errback)\n""", 43 d.addErrback(errback)\n"""
44 } 44 }
45 45
46 def core_completion_signal(self, completion, function, default, arg_doc, async_): 46 def core_completion_signal(self, completion, function, default, arg_doc, async_):
47 completion['args_no_def'] = self.getArguments(function['sig_in'], name=arg_doc) 47 completion["args_no_def"] = self.getArguments(function["sig_in"], name=arg_doc)
48 completion['debug'] = "" if not self.args.debug else 'log.debug ("%s")\n%s' % (completion['name'], 8 * ' ') 48 completion["debug"] = (
49 ""
50 if not self.args.debug
51 else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " ")
52 )
49 53
50 def frontend_completion_method(self, completion, function, default, arg_doc, async_): 54 def frontend_completion_method(self, completion, function, default, arg_doc, async_):
51 completion.update({ 55 completion.update(
52 'args_comma': ', ' if function['sig_in'] else '', 56 {
53 'args_no_def': self.getArguments(function['sig_in'], name=arg_doc), 57 "args_comma": ", " if function["sig_in"] else "",
54 'callback': 'callback' if function['sig_out'] else 'lambda dummy: callback()', 58 "args_no_def": self.getArguments(function["sig_in"], name=arg_doc),
55 'debug': "" if not self.args.debug else 'log.debug ("%s")\n%s' % (completion['name'], 8 * ' '), 59 "callback": "callback"
56 }) 60 if function["sig_out"]
61 else "lambda dummy: callback()",
62 "debug": ""
63 if not self.args.debug
64 else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "),
65 }
66 )