def generate(self): signature = ','.join(get_func_signature(self.func)) fname = self.func.__name__ self.ostream.write("def {}({}):\n".format(fname, signature)) super(FuncGenerator, self).generate() return self.ostream.getvalue()
def __init__(self, model, func, **kwargs): self.model = model self.func = func CodeGenerator.__init__(self, self.func, **kwargs) args = get_func_signature(self.func) signature = "def {}({}):\n".format(self.func.__name__, ", ".join(args)) self.ostream.write(signature)
def extract_signature(self, func): old_signature = get_func_signature(func) new_signature = [] kwargs = None for key in old_signature: if key == 'self': continue elif key[:2] == '**': kwargs = key[2:] continue elif key[1] == '*': raise else: new_signature.append(key.split('=')[0]) return old_signature, new_signature, kwargs
def _extract_signature(self, func): old_signature = get_func_signature(func) new_signature = [] kwargs = None for key in old_signature: if key == "self": continue elif key[:2] == "**": kwargs = key[2:] continue elif key[1] == "*": raise else: new_signature.append(key.split("=")[0]) return old_signature, new_signature, kwargs