Mercurial > repos > shellac > guppy_basecaller
view env/lib/python3.7/site-packages/galaxy/util/aliaspickler.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
line wrap: on
line source
import pickle from six.moves import cStringIO as StringIO class AliasUnpickler(pickle.Unpickler): def __init__(self, aliases, *args, **kw): pickle.Unpickler.__init__(self, *args, **kw) self.aliases = aliases def find_class(self, module, name): module, name = self.aliases.get((module, name), (module, name)) return pickle.Unpickler.find_class(self, module, name) class AliasPickleModule(object): def __init__(self, aliases): self.aliases = aliases def dump(self, obj, fileobj, protocol=0): return pickle.dump(obj, fileobj, protocol) def dumps(self, obj, protocol=0): return pickle.dumps(obj, protocol) def load(self, fileobj): return AliasUnpickler(self.aliases, fileobj).load() def loads(self, string): fileobj = StringIO(string) return AliasUnpickler(self.aliases, fileobj).load()