def seterror_argument(args, func_name): update_mapping() func = None try: func = eval(func_name, namespace) except Exception as e: msg = "Internal error evaluating " + func_name + " :" + str(e) return TypeError, msg sigs = get_signature(func, "typeerror") if type(sigs) != list: sigs = [sigs] if type(args) != tuple: args = (args,) # temp! found = matched_type(args, sigs) if found: msg = dedent(""" '{func_name}' called with wrong argument values: {func_name}{args} Found signature: {func_name}{found} """.format(**locals())).strip() return ValueError, msg type_str = ", ".join(type(arg).__name__ for arg in args) msg = dedent(""" '{func_name}' called with wrong argument types: {func_name}({type_str}) Supported signatures: """.format(**locals())).strip() for sig in sigs: msg += "\n {func_name}{sig}".format(**locals()) # We don't raise the error here, to avoid the loader in the traceback. return TypeError, msg
def pyside_type_init(typemod, sig_str): dprint() if type(typemod) is types.ModuleType: dprint("Initialization of module '{}'".format(typemod.__name__)) else: dprint("Initialization of type '{}.{}'".format(typemod.__module__, typemod.__name__)) update_mapping() lines = fixup_multilines(sig_str) ret = {} multi_props = [] for line in lines: props = calculate_props(line) shortname = props["name"] multi = props["multi"] if multi is None: ret[shortname] = props dprint(props) else: multi_props.append(props) if multi > 0: continue fullname = props.pop("fullname") multi_props = {"multi": multi_props, "fullname": fullname} ret[shortname] = multi_props dprint(multi_props) multi_props = [] return ret
def pyside_type_init(type_key, sig_strings): dprint() dprint("Initialization of type key '{}'".format(type_key)) update_mapping() lines = fixup_multilines(sig_strings) ret = {} multi_props = [] for line in lines: props = calculate_props(line) shortname = props["name"] multi = props["multi"] if multi is None: ret[shortname] = props dprint(props) else: multi_props.append(props) if multi > 0: continue multi_props = {"multi": multi_props} ret[shortname] = multi_props dprint(multi_props) multi_props = [] return ret