Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/galaxy/util/aliaspickler.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import pickle | |
2 from io import StringIO | |
3 | |
4 | |
5 class AliasUnpickler(pickle.Unpickler): | |
6 def __init__(self, aliases, *args, **kw): | |
7 pickle.Unpickler.__init__(self, *args, **kw) | |
8 self.aliases = aliases | |
9 | |
10 def find_class(self, module, name): | |
11 module, name = self.aliases.get((module, name), (module, name)) | |
12 return pickle.Unpickler.find_class(self, module, name) | |
13 | |
14 | |
15 class AliasPickleModule: | |
16 def __init__(self, aliases): | |
17 self.aliases = aliases | |
18 | |
19 def dump(self, obj, fileobj, protocol=0): | |
20 return pickle.dump(obj, fileobj, protocol) | |
21 | |
22 def dumps(self, obj, protocol=0): | |
23 return pickle.dumps(obj, protocol) | |
24 | |
25 def load(self, fileobj): | |
26 return AliasUnpickler(self.aliases, fileobj).load() | |
27 | |
28 def loads(self, string): | |
29 fileobj = StringIO(string) | |
30 return AliasUnpickler(self.aliases, fileobj).load() |