本文整理汇总了Python中pickle.Unpickler.find_class方法的典型用法代码示例。如果您正苦于以下问题:Python Unpickler.find_class方法的具体用法?Python Unpickler.find_class怎么用?Python Unpickler.find_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pickle.Unpickler
的用法示例。
在下文中一共展示了Unpickler.find_class方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
ok = False
for wm in _DjangoQueryUnpickler.white_modules:
if module.startswith(wm):
ok = True
break
if "%s.%s"%(module, name) in _DjangoQueryUnpickler.white_objects:
ok = True
if not ok:
raise UnpicklingError("Unsafe class to unpickle %s.%s"%(module, name))
return Unpickler.find_class(self, module, name)
示例2: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
"""
Helps Unpickler to find certain Numpy modules.
"""
try:
numpy_version = StrictVersion(numpy.__version__)
if numpy_version >= '1.5.0':
if module == 'numpy.core.defmatrix':
module = 'numpy.matrixlib.defmatrix'
except ValueError:
pass
return Unpickler.find_class(self, module, name)
示例3: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
"Backwards-compatibility for changes in module paths"
if module.startswith('eelbrain.'):
if module == 'eelbrain.vessels.data':
module = 'eelbrain._data_obj'
class_names = {'var': 'Var', 'factor': 'Factor', 'ndvar': 'NDVar',
'datalist': 'Datalist', 'dataset': 'Dataset'}
name = class_names[name]
elif module.startswith('eelbrain.data.'):
if module.startswith('eelbrain.data.load'):
module = module.replace('.data.load', '.load')
elif module.startswith('eelbrain.data.stats'):
module = module.replace('.data.stats', '._stats')
elif module.startswith('eelbrain.data.data_obj'):
module = module.replace('.data.data_obj', '._data_obj')
else:
raise NotImplementedError("%r / %r" % (module, name))
return Unpickler.find_class(self, module, name)
示例4: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
try:
return Unpickler.find_class(self, module, name)
except (ImportError, AttributeError):
return dummy
示例5: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
return Unpickler.find_class(self, module_subst.get(module, module), name)
示例6: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
if (module, name) == ('__builtin__', '__main__'):
return self._main_module.__dict__
return Unpickler.find_class(self, module, name)
示例7: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self,module,name):
if module == "datetime":
return Unpickler.find_class(self,module,name)
return DummyClass(module,name)
示例8: find_class
# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import find_class [as 别名]
def find_class(self, module, name):
if (module, name) == ('__builtin__', '__main__'):
return self._main_module.__dict__ #XXX: above set w/save_module_dict
return StockUnpickler.find_class(self, module, name)