def __getJSFunctionsStr(cls, class_): funcStrings = [] functions = inspect.getmembers(class_, predicate=isNewFunction) for name, method in functions: args = getArgs(method) types = ["TYPE_" + l for l in ASCII_UpperCase[: len(args)]] argsTypes = [types[i] + " " + arg for i, arg in enumerate(args)] types = "<" + ", ".join(types) + ">" if len(types) > 0 else "" toJson = "\n\t\t\t\t".join([cls.ARGS_COOK_TEMPLATE.format(arg=a) for a in args]) argsTypes = ", ".join(argsTypes) funcStrings.append(cls.FUNCTION_TEMPLATE.format(name=name, args=argsTypes, types=types, cook=toJson)) return funcStrings
def __getJSFunctionsStr(cls, class_): funcStrings = [] functions = inspect.getmembers(class_.__class__, predicate=isNewFunction) for name, method in functions: defaults = getDefaults(method) args = getArgs(method) defaultsArray = [] for i, d in reversed(list(enumerate(defaults))): defaultsArray.insert(0,cls.ARGS_COOK_TEMPLATE.format(iter = i, name = args[i], default=d)) defaultsStr = "\n\t\t\t".join(defaultsArray) funcStrings.append(cls.FUNCTION_TEMPLATE.format(name=name, args=", ".join(args), cook=defaultsStr)) return funcStrings
def __getFunctionStr(cls, class_): funcStrings = [] functions = inspect.getmembers(class_, predicate=isNewFunction) for name, method in functions: args = getArgs(method) defaults = getDefaults(method) formattedArgs = [] for i, arg in enumerate(reversed(args)): if i >= len(defaults): formattedArgs.insert(0, arg) else: formattedArgs.insert(0, arg + "=" + str(defaults[-i - 1])) appendInArgs = ("\n" + cls.TAB * 4).join([cls.ARGS_COOK_TEMPLATE.format(name=arg) for arg in args]) funcStrings.append( cls.FUNCTION_TEMPLATE.format(name=name, args=", ".join(formattedArgs), cook=appendInArgs)) return funcStrings