mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +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()
|
t.start()
|
||||||
else:
|
else:
|
||||||
f(self, irc, msg, args, *L, **kwargs)
|
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):
|
class UrlSnarfThread(world.SupyThread):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -132,7 +132,7 @@ def urlSnarfer(f):
|
|||||||
L = list(L)
|
L = list(L)
|
||||||
t = UrlSnarfThread(target=doSnarf, url=url)
|
t = UrlSnarfThread(target=doSnarf, url=url)
|
||||||
t.start()
|
t.start()
|
||||||
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
newf = utils.python.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
|
|
||||||
@ -878,6 +878,7 @@ class Spec(object):
|
|||||||
return state
|
return state
|
||||||
|
|
||||||
def wrap(f, specList=[], name=None, **kw):
|
def wrap(f, specList=[], name=None, **kw):
|
||||||
|
name = name or f.func_name
|
||||||
spec = Spec(specList, **kw)
|
spec = Spec(specList, **kw)
|
||||||
def newf(self, irc, msg, args, **kwargs):
|
def newf(self, irc, msg, args, **kwargs):
|
||||||
state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log})
|
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):]
|
funcArgs = inspect.getargs(f.func_code)[0][len(self.commandArgs):]
|
||||||
self.log.error('Extra args: %s', funcArgs)
|
self.log.error('Extra args: %s', funcArgs)
|
||||||
raise
|
raise
|
||||||
return utils.changeFunctionName(newf, name or f.func_name, f.__doc__)
|
return utils.python.changeFunctionName(newf, name, f.__doc__)
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
# Contexts.
|
# Contexts.
|
||||||
|
@ -325,7 +325,7 @@ def firewall(f, errorHandler=None):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
logException(self, 'Uncaught exception in errorHandler')
|
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
|
return m
|
||||||
|
|
||||||
class MetaFirewall(type):
|
class MetaFirewall(type):
|
||||||
|
@ -128,7 +128,7 @@ class PluginTestCase(SupyTestCase):
|
|||||||
run = False
|
run = False
|
||||||
if run:
|
if run:
|
||||||
originalRunTest()
|
originalRunTest()
|
||||||
runTest = utils.changeFunctionName(runTest, methodName)
|
runTest = utils.python.changeFunctionName(runTest, methodName)
|
||||||
setattr(self.__class__, methodName, runTest)
|
setattr(self.__class__, methodName, runTest)
|
||||||
SupyTestCase.__init__(self, methodName=methodName)
|
SupyTestCase.__init__(self, methodName=methodName)
|
||||||
self.originals = {}
|
self.originals = {}
|
||||||
|
@ -218,14 +218,6 @@ class IterableMap(object):
|
|||||||
return False
|
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):
|
class InsensitivePreservingDict(UserDict.DictMixin, object):
|
||||||
def key(self, s):
|
def key(self, s):
|
||||||
"""Override this if you wish."""
|
"""Override this if you wish."""
|
||||||
|
@ -27,6 +27,16 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# 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):
|
class Object(object):
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self == other
|
return not self == other
|
||||||
|
Loading…
Reference in New Issue
Block a user