Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.util.aliaspickler

import pickle

from six.moves import cStringIO as StringIO


[docs]class AliasUnpickler(pickle.Unpickler):
[docs] def __init__(self, aliases, *args, **kw): pickle.Unpickler.__init__(self, *args, **kw) self.aliases = aliases
[docs] def find_class(self, module, name): module, name = self.aliases.get((module, name), (module, name)) return pickle.Unpickler.find_class(self, module, name)
[docs]class AliasPickleModule(object):
[docs] def __init__(self, aliases): self.aliases = aliases
[docs] def dump(self, obj, fileobj, protocol=0): return pickle.dump(obj, fileobj, protocol)
[docs] def dumps(self, obj, protocol=0): return pickle.dumps(obj, protocol)
[docs] def load(self, fileobj): return AliasUnpickler(self.aliases, fileobj).load()
[docs] def loads(self, string): fileobj = StringIO(string) return AliasUnpickler(self.aliases, fileobj).load()