From db2a8e8fb300bda79a16dadc084df87f13dc161b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 27 Nov 2006 01:27:10 +0000 Subject: [PATCH] removed old function --- lib/sqlalchemy/util.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index bd40039d4e..a4370edaf3 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -259,43 +259,3 @@ class ScopedRegistry(object): return self.scopefunc() -def constructor_args(instance, **kwargs): - """given an object instance and keyword arguments, inspects the - argument signature of the instance's __init__ method and returns - a tuple of list and keyword arguments, suitable for creating a new - instance of the class. The returned arguments are drawn from the - given keyword dictionary, or if not found are drawn from the - corresponding attributes of the original instance.""" - classobj = instance.__class__ - - argspec = inspect.getargspec(classobj.__init__.im_func) - - argnames = argspec[0] or [] - defaultvalues = argspec[3] or [] - - (requiredargs, namedargs) = ( - argnames[0:len(argnames) - len(defaultvalues)], - argnames[len(argnames) - len(defaultvalues):] - ) - - newparams = {} - - for arg in requiredargs: - if arg == 'self': - continue - elif kwargs.has_key(arg): - newparams[arg] = kwargs[arg] - else: - newparams[arg] = getattr(instance, arg) - - for arg in namedargs: - if kwargs.has_key(arg): - newparams[arg] = kwargs[arg] - else: - if hasattr(instance, arg): - newparams[arg] = getattr(instance, arg) - else: - raise AssertionError("instance has no attribute '%s'" % arg) - - return newparams - -- 2.47.2