~mdw
/
distorted-keys
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
extract-profile.in: Allow empty sections.
[distorted-keys]
/
extract-profile.in
diff --git
a/extract-profile.in
b/extract-profile.in
index
c3a224b
..
918da8c
100755
(executable)
--- a/
extract-profile.in
+++ b/
extract-profile.in
@@
-279,7
+279,7
@@
class Section (object, UD.DictMixin):
left = dol + 1
while left < n and (string[left].isalnum() or string[left] in '-_'):
left += 1
left = dol + 1
while left < n and (string[left].isalnum() or string[left] in '-_'):
left += 1
- prop = string[dol + 1:left]
.replace('-', '_')
+ prop = string[dol + 1:left]
## If we came up empty, report an error.
if prop == '':
## If we came up empty, report an error.
if prop == '':
@@
-287,6
+287,7
@@
class Section (object, UD.DictMixin):
"invalid placeholder (empty name) in `%s'" % string
## Extend the path: we're going to do a recursive expansion.
"invalid placeholder (empty name) in `%s'" % string
## Extend the path: we're going to do a recursive expansion.
+ prop = prop.replace('-', '_')
path.append(prop)
## Report a cycle if we found one.
path.append(prop)
## Report a cycle if we found one.
@@
-375,6
+376,8
@@
def parse(filename, d):
continue
if line[0] == '[' and line[-1] == ']':
sect = line[1:-1]
continue
if line[0] == '[' and line[-1] == ']':
sect = line[1:-1]
+ if sect not in d:
+ d[sect] = Section(sect)
continue
## Parse an assignment.
continue
## Parse an assignment.
@@
-392,12
+395,7
@@
def parse(filename, d):
raise UserError, "%s:%d: bad name `%s'" % (filename, n, name)
## Store the assignment.
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.
###--------------------------------------------------------------------------
### Main program.