Mercurial > libervia-backend
comparison src/bridge/bridge_constructor/base_constructor.py @ 2087:159250d66407
bridge (constructor): embedded bridge generator:
"embedded" is used to have backend and frontend together in the same process (frontend call backend as a module).
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 Oct 2016 22:07:51 +0200 |
parents | da4097de5a95 |
children | f413bfc24458 |
comparison
equal
deleted
inserted
replaced
2086:4633cfcbcccb | 2087:159250d66407 |
---|---|
46 CORE_TEMPLATE = None | 46 CORE_TEMPLATE = None |
47 CORE_DEST = None | 47 CORE_DEST = None |
48 FRONTEND_FORMATS = None | 48 FRONTEND_FORMATS = None |
49 FRONTEND_TEMPLATE = None | 49 FRONTEND_TEMPLATE = None |
50 FRONTEND_DEST = None | 50 FRONTEND_DEST = None |
51 | |
52 # set to False if your bridge need only core | |
53 FRONTEND_ACTIVATE = True | |
51 | 54 |
52 def __init__(self, bridge_template, options): | 55 def __init__(self, bridge_template, options): |
53 self.bridge_template = bridge_template | 56 self.bridge_template = bridge_template |
54 self.args = options | 57 self.args = options |
55 | 58 |
168 | 171 |
169 def getArguments(self, signature, name=None, default=None, unicode_protect=False): | 172 def getArguments(self, signature, name=None, default=None, unicode_protect=False): |
170 """Return arguments to user given a signature | 173 """Return arguments to user given a signature |
171 | 174 |
172 @param signature: signature in the short form (using s,a,i,b etc) | 175 @param signature: signature in the short form (using s,a,i,b etc) |
173 @param name: dictionary of arguments name like given by getArguments | 176 @param name: dictionary of arguments name like given by getArgumentsDoc |
174 @param default: dictionary of default values, like given by getDefault | 177 @param default: dictionary of default values, like given by getDefault |
175 @param unicode_protect: activate unicode protection on strings (return strings as unicode(str)) | 178 @param unicode_protect: activate unicode protection on strings (return strings as unicode(str)) |
176 @return: list of arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3") | 179 @return: list of arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3") |
177 """ | 180 """ |
178 idx = 0 | 181 idx = 0 |
220 """ | 223 """ |
221 try: | 224 try: |
222 if side == "core": | 225 if side == "core": |
223 method = self.generateCoreSide | 226 method = self.generateCoreSide |
224 elif side == "frontend": | 227 elif side == "frontend": |
228 if not self.FRONTEND_ACTIVATE: | |
229 print(u"This constructor only handle core, please use core side") | |
230 sys.exit(1) | |
225 method = self.generateFrontendSide | 231 method = self.generateFrontendSide |
226 except AttributeError: | 232 except AttributeError: |
227 self._generate(side) | 233 self._generate(side) |
228 else: | 234 else: |
229 method() | 235 method() |
258 completion = { | 264 completion = { |
259 'sig_in': function['sig_in'] or '', | 265 'sig_in': function['sig_in'] or '', |
260 'sig_out': function['sig_out'] or '', | 266 'sig_out': function['sig_out'] or '', |
261 'category': 'plugin' if function['category'] == 'plugin' else 'core', | 267 'category': 'plugin' if function['category'] == 'plugin' else 'core', |
262 'name': section, | 268 'name': section, |
263 'args': self.getArguments(function['sig_in'], name=arg_doc, default=default)} | 269 # arguments with default values |
270 'args': self.getArguments(function['sig_in'], name=arg_doc, default=default), | |
271 } | |
264 | 272 |
265 extend_method = getattr(self, "{}_completion_{}".format(side, function["type"])) | 273 extend_method = getattr(self, "{}_completion_{}".format(side, function["type"])) |
266 extend_method(completion, function, default, arg_doc, async_) | 274 extend_method(completion, function, default, arg_doc, async_) |
267 | 275 |
268 for part, fmt in FORMATS.iteritems(): | 276 for part, fmt in FORMATS.iteritems(): |