[SCM] morituri/master: Allow getting normal and boolean from config

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:10:05 UTC 2014


The following commit has been merged in the master branch:
commit 8e2db21a55e826aa1f43db2856d820c1f298b099
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sat Jul 13 18:50:18 2013 +0200

    Allow getting normal and boolean from config

diff --git a/morituri/common/config.py b/morituri/common/config.py
index 125f87f..109dfed 100644
--- a/morituri/common/config.py
+++ b/morituri/common/config.py
@@ -54,6 +54,32 @@ class Config(log.Loggable):
         self.info('Loaded %d sections from config file' %
             len(self._parser.sections()))
 
+    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)
+
+
+    ### any section
+
+    def _getter(self, suffix, section, option):
+        methodName = 'get' + suffix
+        method = getattr(self._parser, methodName)
+        try:
+            return method(section, option)
+        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+            return None
+
+    def get(self, section, option):
+        return self._getter('', section, option)
+
+    def getboolean(self, section, option):
+        return self._getter('boolean', section, option)
+
+    ### drive sections
+
     def setReadOffset(self, vendor, model, release, offset):
         """
         Set a read offset for the given drive.
@@ -96,13 +122,6 @@ class Config(log.Loggable):
             raise KeyError("Could not find defeats_cache for %s/%s/%s" % (
                 vendor, model, release))
 
-    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:'):

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list