def find_class(self, module, name):
"""
Overridden from the original 'Unpickler' class. Needed to rebuild PyMod object which have
complex modules names. 'Unpickler' rebuilds objects using the 'fully qualified' name
reference of their classes (the class name is pickled, along with the name of the module the
class is defined in). Since PyMOL plugin modules may yield different 'fully qualified' names
depending on the system, PyMod objects are rebuilt using only the name of their classes.
"""
try:
# Try the standard routine of pickle.
__import__(module)
mod = sys.modules[module]
klass = getattr(mod, name)
return klass
except:
# Build object by class name.
try:
name = name.rstrip("\n\r") # Needed to fix some old Windows versions behaviour.
except:
pass
return globals()[name]
评论列表
文章目录