diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/env/lib/python3.7/site-packages/galaxy/util/aliaspickler.py	Sat May 02 07:14:21 2020 -0400
@@ -0,0 +1,31 @@
+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()