Adds multiple group support for config options in

autohelp.py

Change-Id: I8055c897dc9d063fc304e0b5016f64b0a753b173
Closes-Bug: 1259206
This commit is contained in:
Bob Callaway 2013-12-09 14:06:08 -05:00
parent 95617e3829
commit ccde3f5a3f
2 changed files with 8 additions and 6 deletions

View File

@ -54,14 +54,14 @@ eg
2) Grouping of flags
This is currently done manually, by using the flag name file and placing
a category after a space.
one or more categories after a space.
eg
$ head flagmappings/glance.flagmappings
admin\_password registry
admin\_password registry api
admin\_role api
admin\_tenant\_name registry
admin\_tenant\_name registry api
admin\_user registry
...

View File

@ -37,18 +37,20 @@ def populate_groups(filepath):
"""
Takes a file formatted with lines of config option and group
separated by a space and constructs a dictionary indexed by
group, which is returned..
group, which is returned.
"""
groups = defaultdict(list)
groups_file = open(os.path.expanduser(filepath), 'r')
for line in groups_file:
try:
option, group = line.split(None, 1)
option, group_list = line.split(None, 1)
group_list = group_list.split(None)
except ValueError:
print "Couldn't read groups file line:%s" % line
print "Check for formatting errors - did you add the group?"
sys.exit(1)
groups[group.strip()].append(option)
for group in group_list:
groups[group.strip()].append(option)
return groups