[SCM] morituri/master: * morituri/common/common.py: Remove migrated classes.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:09:48 UTC 2014


The following commit has been merged in the master branch:
commit 5c4a63c1abd111ce27b09b1d5837ad6b58889b3b
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sun Dec 2 17:54:37 2012 +0000

    	* morituri/common/common.py:
    	  Remove migrated classes.

diff --git a/ChangeLog b/ChangeLog
index 3496bff..03763e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2012-12-02  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+	* morituri/common/common.py:
+	  Remove migrated classes.
+
+2012-12-02  Thomas Vander Stichele  <thomas at apestaart dot org>
+
 	* morituri/common/cache.py:
 	  Disable the version-based persistence deleting.
 	  Allow not creating a fresh ripresult when getting one.
diff --git a/morituri/common/common.py b/morituri/common/common.py
index 3c8b46f..354d3b2 100644
--- a/morituri/common/common.py
+++ b/morituri/common/common.py
@@ -119,119 +119,6 @@ def formatTime(seconds, fractional=3):
     return " ".join(chunks)
 
 
-class Persister(object):
-    """
-    I wrap an optional pickle to persist an object to disk.
-
-    Instantiate me with a path to automatically unpickle the object.
-    Call persist to store the object to disk; it will get stored if it
-    changed from the on-disk object.
-
-    @ivar object: the persistent object
-    """
-
-    def __init__(self, path=None, default=None):
-        """
-        If path is not given, the object will not be persisted.
-        This allows code to transparently deal with both persisted and
-        non-persisted objects, since the persist method will just end up
-        doing nothing.
-        """
-        self._path = path
-        self.object = None
-
-        self._unpickle(default)
-
-    def persist(self, obj=None):
-        """
-        Persist the given object, if we have a persistence path and the
-        object changed.
-
-        If object is not given, re-persist our object, always.
-        If object is given, only persist if it was changed.
-        """
-        # don't pickle if it's already ok
-        if obj and obj == self.object:
-            return
-
-        # store the object on ourselves if not None
-        if obj is not None:
-            self.object = obj
-
-        # don't pickle if there is no path
-        if not self._path:
-            return
-
-        # default to pickling our object again
-        if obj is None:
-            obj = self.object
-
-        # pickle
-        self.object = obj
-        (fd, path) = tempfile.mkstemp(suffix='.morituri.pickle')
-        handle = os.fdopen(fd, 'wb')
-        import pickle
-        pickle.dump(obj, handle, 2)
-        handle.close()
-        # do an atomic move
-        shutil.move(path, self._path)
-
-    def _unpickle(self, default=None):
-        self.object = default
-
-        if not self._path:
-            return None
-
-        if not os.path.exists(self._path):
-            return None
-
-        handle = open(self._path)
-        import pickle
-
-        try:
-            self.object = pickle.load(handle)
-        except:
-            # can fail for various reasons; in that case, pretend we didn't
-            # load it
-            pass
-
-    def delete(self):
-        self.object = None
-        os.unlink(self._path)
-
-
-class PersistedCache(object):
-    """
-    I wrap a directory of persisted objects.
-    """
-
-    path = None
-
-    def __init__(self, path):
-        self.path = path
-        try:
-            os.makedirs(self.path)
-        except OSError, e:
-            if e.errno != 17: # FIXME
-                raise
-
-    def _getPath(self, key):
-        return os.path.join(self.path, '%s.pickle' % key)
-
-    def get(self, key):
-        """
-        Returns the persister for the given key.
-        """
-        persister = Persister(self._getPath(key))
-        if persister.object:
-            if hasattr(persister.object, 'instanceVersion'):
-                o = persister.object
-                if o.instanceVersion < o.__class__.classVersion:
-                    persister.delete()
-
-        return persister
-
-
 def tagListToDict(tl):
     """
     Removes audio-codec and video-codec since we never set them ourselves.

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list