home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __docformat__ = 'restructuredtext en'
- from types import FunctionType
- from twisted.python import log
-
- class CannedObject(object):
- pass
-
-
- class CannedFunction(CannedObject):
-
- def __init__(self, f):
- self._checkType(f)
- self.code = f.func_code
-
-
- def _checkType(self, obj):
- pass
-
-
- def getFunction(self, g = None):
- if g is None:
- g = globals()
-
- newFunc = FunctionType(self.code, g)
- return newFunc
-
-
-
- def can(obj):
- if isinstance(obj, FunctionType):
- return CannedFunction(obj)
- return obj
-
-
- def canDict(obj):
- if isinstance(obj, dict):
- for k, v in obj.iteritems():
- obj[k] = can(v)
-
- return obj
- return obj
-
-
- def canSequence(obj):
- if isinstance(obj, (list, tuple)):
- t = type(obj)
- return []([ can(i) for i in obj ])
- return obj
-
-
- def uncan(obj, g = None):
- if isinstance(obj, CannedFunction):
- return obj.getFunction(g)
- return obj
-
-
- def uncanDict(obj, g = None):
- if isinstance(obj, dict):
- for k, v in obj.iteritems():
- obj[k] = uncan(v, g)
-
- return obj
- return obj
-
-
- def uncanSequence(obj, g = None):
- if isinstance(obj, (list, tuple)):
- t = type(obj)
- return []([ uncan(i, g) for i in obj ])
- return obj
-
-
- def rebindFunctionGlobals(f, glbls):
- return FunctionType(f.func_code, glbls)
-
-