def set_options_from_dict(self, config): """ Reads the configuration from a dictionary. raises: UserError: Wrong configuration, user's mistake. Exception: all other exceptions """ params = DecentParams() self.define_program_options(params) try: self.options = params.get_dpr_from_dict(config) except DecentParamsUserError as e: raise QuickAppException(str(e)) except Exception as e: msg = 'Could not interpret:\n' msg += indent(pformat(config), '| ') msg += 'according to params spec:\n' msg += indent(str(params), '| ') + '\n' msg += 'Error is:\n' # if isinstance(e, DecentParamsUserError): # msg += indent(str(e), '> ') # else: msg += indent(traceback.format_exc(e), '> ') raise QuickAppException(msg) # XXX class
def set_options_from_dict(self, config: Dict[str, Any]): """ Reads the configuration from a dictionary. raises: UserError: Wrong configuration, user's mistake. Exception: all other exceptions """ params = DecentParams() self.define_program_options(params) try: self.options = params.get_dpr_from_dict(config) except DecentParamsUserError as e: raise QuickAppException(str(e)) except Exception as e: msg = 'Could not interpret:\n' msg += indent(pformat(config), '| ') msg += 'according to params spec:\n' msg += indent(str(params), '| ') + '\n' msg += 'Error is:\n' # if isinstance(e, DecentParamsUserError): # msg += indent(str(e), '> ') # else: msg += indent(traceback.format_exc(), '> ') raise QuickAppException(msg) # XXX class
def parse_mcdpweb_params_from_dict(x): dp = DecentParams() describe_mcdpweb_params(dp) return dp.get_dpr_from_dict(x)