[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.50-20-gdf38a79

Andreas Beckmann anbe at debian.org
Wed Mar 20 22:04:05 UTC 2013


The following commit has been merged in the develop branch:
commit df38a7982ee15d4301418670ef3abb97405c57a8
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon Mar 18 10:05:18 2013 +0100

    lib/conf: raise MissingSection if section is not in piuparts.conf
    
    avoids creating directory trees for misspelled sections
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>

diff --git a/debian/changelog b/debian/changelog
index 93c9104..32f8724 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,8 @@ piuparts (0.51) UNRELEASED; urgency=low
       package to be tested via --extra-old-packages.
   * piuparts.conf:
   * distros.conf:
+  * piupartslib/conf.py:
+    - Raise MissingSection if the requested section is not in piuparts.conf.
   * piupartslib/packagesdb.py:
   * Rename piuparts-master.py to piuparts-master-backend.py
   * piuparts-master: New.
diff --git a/piupartslib/conf.py b/piupartslib/conf.py
index 1d58d6f..da2e34b 100644
--- a/piupartslib/conf.py
+++ b/piupartslib/conf.py
@@ -27,6 +27,13 @@ import UserDict
 import subprocess
 
 
+class MissingSection(Exception):
+
+    def __init__(self, filename, section):
+        self.args = "Section %s not defined in configuration file %s" % \
+            (section, filename)
+
+
 class MissingMandatorySetting(Exception):
 
     def __init__(self, filename, key):
@@ -47,6 +54,8 @@ class Config(UserDict.UserDict):
     def read(self, filename):
         cp = ConfigParser.ConfigParser()
         cp.read(filename)
+        if not cp.has_section(self._section):
+            raise MissingSection(filename, self._section)
         for key in self.keys():
             if cp.has_option(self._section, key):
                 self[key] = cp.get(self._section, key)

-- 
piuparts git repository



More information about the Piuparts-commits mailing list