extract-profile.in: Allow empty sections.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 25 Dec 2011 23:55:59 +0000 (23:55 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 26 Dec 2011 00:08:44 +0000 (00:08 +0000)
Create a section as soon as we see a section header; we no longer need
the more complicated lazy creation code.

extract-profile.in

index dc816f3..918da8c 100755 (executable)
@@ -376,6 +376,8 @@ def parse(filename, d):
         continue
       if line[0] == '[' and line[-1] == ']':
         sect = line[1:-1]
+        if sect not in d:
+          d[sect] = Section(sect)
         continue
 
       ## Parse an assignment.
@@ -393,12 +395,7 @@ def parse(filename, d):
         raise UserError, "%s:%d: bad name `%s'" % (filename, n, name)
 
       ## Store the assignment.
-      try:
-        d[sect][name] = value
-      except KeyError:
-        s = Section(sect)
-        d[sect] = s
-        s[name] = value
+      d[sect][name] = value
 
 ###--------------------------------------------------------------------------
 ### Main program.