Mercurial > repos > shellac > guppy_basecaller
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 import pickle | |
| 2 | |
| 3 from six.moves import cStringIO as StringIO | |
| 4 | |
| 5 | |
| 6 class AliasUnpickler(pickle.Unpickler): | |
| 7 def __init__(self, aliases, *args, **kw): | |
| 8 pickle.Unpickler.__init__(self, *args, **kw) | |
| 9 self.aliases = aliases | |
| 10 | |
| 11 def find_class(self, module, name): | |
| 12 module, name = self.aliases.get((module, name), (module, name)) | |
| 13 return pickle.Unpickler.find_class(self, module, name) | |
| 14 | |
| 15 | |
| 16 class AliasPickleModule(object): | |
| 17 def __init__(self, aliases): | |
| 18 self.aliases = aliases | |
| 19 | |
| 20 def dump(self, obj, fileobj, protocol=0): | |
| 21 return pickle.dump(obj, fileobj, protocol) | |
| 22 | |
| 23 def dumps(self, obj, protocol=0): | |
| 24 return pickle.dumps(obj, protocol) | |
| 25 | |
| 26 def load(self, fileobj): | |
| 27 return AliasUnpickler(self.aliases, fileobj).load() | |
| 28 | |
| 29 def loads(self, string): | |
| 30 fileobj = StringIO(string) | |
| 31 return AliasUnpickler(self.aliases, fileobj).load() |
