Mercurial > libervia-backend
comparison frontends/src/jp/base.py @ 2187:4ec72927a222
jp (outputs): moved output options parsing and checking to base methods
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Mar 2017 23:31:06 +0100 |
parents | b9bfc45cea22 |
children | 052d560d0dce |
comparison
equal
deleted
inserted
replaced
2186:9061c7247964 | 2187:4ec72927a222 |
---|---|
315 log.error(u"Invalid output type {}".format(type_)) | 315 log.error(u"Invalid output type {}".format(type_)) |
316 return | 316 return |
317 self._outputs[type_][name] = {'callback': callback, | 317 self._outputs[type_][name] = {'callback': callback, |
318 'description': description | 318 'description': description |
319 } | 319 } |
320 | |
321 def parse_output_options(self): | |
322 options = self.command.args.output_opts | |
323 options_dict = {} | |
324 for option in options: | |
325 try: | |
326 key, value = option.split(u'=', 1) | |
327 except ValueError: | |
328 key, value = option, None | |
329 options_dict[key.strip()] = value.strip() if value is not None else None | |
330 return options_dict | |
331 | |
332 def check_output_options(self, accepted_set, options): | |
333 if not accepted_set.issuperset(options): | |
334 self.disp(u"The following output options are invalid: {invalid_options}".format( | |
335 invalid_options = u', '.join(set(options).difference(accepted_set))), | |
336 error=True) | |
337 self.quit(C.EXIT_BAD_ARG) | |
320 | 338 |
321 def import_plugins(self): | 339 def import_plugins(self): |
322 """Automaticaly import commands and outputs in jp | 340 """Automaticaly import commands and outputs in jp |
323 | 341 |
324 looks from modules names cmd_*.py in jp path and import them | 342 looks from modules names cmd_*.py in jp path and import them |