def fn_typecheck(*args): inp = args[-1] if type_in is not None: try: inp = type_in.create_from(inp) except TypeConversionError as e: panic("Incompatible input type: expected '{}', got '{}'".format(e.type_to, e.type_from)) if len(args) > 1: result = fn(*args[0:-1], inp=inp.value) else: result = fn(inp=inp.value) if type_out is None: return TypedValue(result, inp.fttype) elif type_out == "returned": return result return TypedValue(result, type_out)
def duplicate(inp): return [TypedValue(inp, T_STRING), TypedValue(inp, T_STRING)]
def split_ext(inp): parts = os.path.splitext(inp) return [TypedValue(parts[0], T_STRING), TypedValue(parts[1][1:], T_STRING)]