[SCM] morituri/master: * morituri/common/config.py: Add methods to get/set defeating of audio cache. Make sure that we set read offset even if section is already there.

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


The following commit has been merged in the master branch:
commit 7545829764b243b6d44a4680dfa09f8fecc0faa9
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Tue Dec 4 00:12:38 2012 +0000

    	* morituri/common/config.py:
    	  Add methods to get/set defeating of audio cache.
    	  Make sure that we set read offset even if section is already there.

diff --git a/ChangeLog b/ChangeLog
index 5082140..455919c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-04  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* morituri/common/config.py:
+	  Add methods to get/set defeating of audio cache.
+	  Make sure that we set read offset even if section is already there.
+
 2012-12-03  Thomas Vander Stichele  <thomas at apestaart dot org>
 
 	* morituri/common/task.py:
diff --git a/morituri/common/config.py b/morituri/common/config.py
index 3d052a7..dcf1cc4 100644
--- a/morituri/common/config.py
+++ b/morituri/common/config.py
@@ -71,17 +71,8 @@ class Config(log.Loggable):
 
         Strips the given strings of leading and trailing whitespace.
         """
-        try:
-            section = self._findDriveSection(vendor, model, release)
-        except KeyError:
-            section = 'drive:' + urllib.quote('%s:%s:%s' % (
-                vendor, model, release))
-            self._parser.add_section(section)
-            __pychecker__ = 'no-local'
-            read_offset = str(offset)
-            for key in ['vendor', 'model', 'release', 'read_offset']:
-                self._parser.set(section, key, locals()[key].strip())
-
+        section = self._findOrCreateDriveSection(vendor, model, release)
+        self._parser.set(section, 'read_offset', str(offset))
         self.write()
 
     def getReadOffset(self, vendor, model, release):
@@ -92,6 +83,28 @@ class Config(log.Loggable):
 
         return int(self._parser.get(section, 'read_offset'))
 
+    def setDefeatsCache(self, vendor, model, release, defeat):
+        """
+        Set whether the drive defeats the cache.
+
+        Strips the given strings of leading and trailing whitespace.
+        """
+        section = self._findOrCreateDriveSection(vendor, model, release)
+        self._parser.set(section, 'defeats_cache', str(defeat))
+        self.write()
+
+    def getDefeatsCache(self, vendor, model, release):
+        section = self._findDriveSection(vendor, model, release)
+
+        return bool(self._parser.get(section, 'defeats_cache'))
+
+    def write(self):
+        fd, path = tempfile.mkstemp(suffix=u'.moriturirc')
+        handle = os.fdopen(fd, 'w')
+        self._parser.write(handle)
+        handle.close()
+        shutil.move(path, self._path)
+
     def _findDriveSection(self, vendor, model, release):
         for name in self._parser.sections():
             if not name.startswith('drive:'):
@@ -115,9 +128,19 @@ class Config(log.Loggable):
 
         raise KeyError
 
-    def write(self):
-        fd, path = tempfile.mkstemp(suffix=u'.moriturirc')
-        handle = os.fdopen(fd, 'w')
-        self._parser.write(handle)
-        handle.close()
-        shutil.move(path, self._path)
+    def _findOrCreateDriveSection(self, vendor, model, release):
+        try:
+            section = self._findDriveSection(vendor, model, release)
+        except KeyError:
+            section = 'drive:' + urllib.quote('%s:%s:%s' % (
+                vendor, model, release))
+            self._parser.add_section(section)
+            __pychecker__ = 'no-local'
+            for key in ['vendor', 'model', 'release']:
+                self._parser.set(section, key, locals()[key].strip())
+
+        self.write()
+
+        return self._findDriveSection(vendor, model, release)
+
+

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list