mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-28 05:32:51 +01:00
Moved utils.changeFunctionName to utils.python.
This commit is contained in:
parent
1d357dd470
commit
2394005cdd
@ -64,7 +64,7 @@ def thread(f):
|
||||
t.start()
|
||||
else:
|
||||
f(self, irc, msg, args, *L, **kwargs)
|
||||
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||
return utils.python.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||
|
||||
class UrlSnarfThread(world.SupyThread):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -132,7 +132,7 @@ def urlSnarfer(f):
|
||||
L = list(L)
|
||||
t = UrlSnarfThread(target=doSnarf, url=url)
|
||||
t.start()
|
||||
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||
newf = utils.python.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||
return newf
|
||||
|
||||
|
||||
@ -878,6 +878,7 @@ class Spec(object):
|
||||
return state
|
||||
|
||||
def wrap(f, specList=[], name=None, **kw):
|
||||
name = name or f.func_name
|
||||
spec = Spec(specList, **kw)
|
||||
def newf(self, irc, msg, args, **kwargs):
|
||||
state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log})
|
||||
@ -890,7 +891,7 @@ def wrap(f, specList=[], name=None, **kw):
|
||||
funcArgs = inspect.getargs(f.func_code)[0][len(self.commandArgs):]
|
||||
self.log.error('Extra args: %s', funcArgs)
|
||||
raise
|
||||
return utils.changeFunctionName(newf, name or f.func_name, f.__doc__)
|
||||
return utils.python.changeFunctionName(newf, name, f.__doc__)
|
||||
|
||||
__all__ = [
|
||||
# Contexts.
|
||||
|
@ -325,7 +325,7 @@ def firewall(f, errorHandler=None):
|
||||
except Exception, e:
|
||||
logException(self, 'Uncaught exception in errorHandler')
|
||||
|
||||
m = utils.gen.changeFunctionName(m, f.func_name, f.__doc__)
|
||||
m = utils.python.changeFunctionName(m, f.func_name, f.__doc__)
|
||||
return m
|
||||
|
||||
class MetaFirewall(type):
|
||||
|
@ -128,7 +128,7 @@ class PluginTestCase(SupyTestCase):
|
||||
run = False
|
||||
if run:
|
||||
originalRunTest()
|
||||
runTest = utils.changeFunctionName(runTest, methodName)
|
||||
runTest = utils.python.changeFunctionName(runTest, methodName)
|
||||
setattr(self.__class__, methodName, runTest)
|
||||
SupyTestCase.__init__(self, methodName=methodName)
|
||||
self.originals = {}
|
||||
|
@ -218,14 +218,6 @@ class IterableMap(object):
|
||||
return False
|
||||
|
||||
|
||||
def changeFunctionName(f, name, doc=None):
|
||||
if doc is None:
|
||||
doc = f.__doc__
|
||||
newf = types.FunctionType(f.func_code, f.func_globals, name,
|
||||
f.func_defaults, f.func_closure)
|
||||
newf.__doc__ = doc
|
||||
return newf
|
||||
|
||||
class InsensitivePreservingDict(UserDict.DictMixin, object):
|
||||
def key(self, s):
|
||||
"""Override this if you wish."""
|
||||
|
@ -27,6 +27,16 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import types
|
||||
|
||||
def changeFunctionName(f, name, doc=None):
|
||||
if doc is None:
|
||||
doc = f.__doc__
|
||||
newf = types.FunctionType(f.func_code, f.func_globals, name,
|
||||
f.func_defaults, f.func_closure)
|
||||
newf.__doc__ = doc
|
||||
return newf
|
||||
|
||||
class Object(object):
|
||||
def __ne__(self, other):
|
||||
return not self == other
|
||||
|
Loading…
Reference in New Issue
Block a user