[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.44-755-ga3ab31d

Andreas Beckmann debian at abeckmann.de
Mon Jun 18 11:38:13 UTC 2012


The following commit has been merged in the piatti branch:
commit 9c2b9c1984e390931440e78d31fc8b39faade4cb
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Thu Jun 14 17:58:40 2012 +0200

    lib/conf: add support for loading defaults from a special section
    
    To avoid repeating common settings again and again while having
    the possibility to override them where needed.
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index 0efb985..4a6fda0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -84,6 +84,8 @@ piuparts (0.45) UNRELEASED; urgency=low
         Affects: package-under-test
         Found: package-under-test/tested-version
     - Reschedule /affected/ logs like /fail/ logs.
+  * piupartslib/conf.py:
+    - Add support for getting default values from a special section.
   * piupartslib/packagesdb.py:
     - Do not consider a package as "untestable" if untestable/ contains a
       logfile from an obsolete version of that package.
diff --git a/piupartslib/conf.py b/piupartslib/conf.py
index cb8a2eb..033aa71 100644
--- a/piupartslib/conf.py
+++ b/piupartslib/conf.py
@@ -34,9 +34,10 @@ class MissingMandatorySetting(Exception):
 
 class Config(UserDict.UserDict):
 
-    def __init__(self, section, defaults, mandatory=[]):
+    def __init__(self, section, defaults, mandatory=[], defaults_section=None):
         UserDict.UserDict.__init__(self)
         self._section = section
+        self._defaults_section = defaults_section
         for key, value in defaults.iteritems():
             self[key] = value
         self._mandatory = mandatory
@@ -47,6 +48,8 @@ class Config(UserDict.UserDict):
         for key in self.keys():
             if cp.has_option(self._section, key):
                 self[key] = cp.get(self._section, key)
+            elif self._defaults_section and cp.has_option(self._defaults_section, key):
+                self[key] = cp.get(self._defaults_section, key)
             elif key in self._mandatory:
                 raise MissingMandatorySetting(filename, key)
 

-- 
piuparts git repository



More information about the Piuparts-commits mailing list