Re-factor the option parsing following a suggestion from Greg.
Eliminate the <topic>.parse altogether.
Signed-off-by: Jean-Marc Eurin <jmeurin@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3081 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/atomicgroup.py b/cli/atomicgroup.py
index 429569b..8384d13 100644
--- a/cli/atomicgroup.py
+++ b/cli/atomicgroup.py
@@ -35,12 +35,10 @@
type='string', default=None,
metavar='ATOMIC_GROUP_FLIST')
-
- def parse(self, flists=None, req_items='atomicgroups'):
- if not flists:
- flists = []
- flists.append(('atomicgroups', 'glist', '', True))
- return self.parse_with_flist(flists, req_items)
+ self.topic_parse_info = topic_common.item_parse_info(
+ attribute_name='atomicgroups',
+ filename_option='glist',
+ use_leftover=True)
def get_items(self):
@@ -62,7 +60,7 @@
def parse(self):
- options, leftover = super(atomicgroup_list, self).parse(req_items=None)
+ options, leftover = super(atomicgroup_list, self).parse()
self.show_invalid = options.show_invalid
return options, leftover
@@ -125,8 +123,13 @@
def parse(self):
- flists = [('labels', 'label_list', 'label', False)]
- options, leftover = super(atomicgroup_add_or_remove, self).parse(flists)
+ label_info = topic_common.item_parse_info(attribute_name='labels',
+ inline_option='label',
+ filename_option='label_list')
+
+ options, leftover = super(atomicgroup_add_or_remove,
+ self).parse([label_info],
+ req_items='atomicgroups')
if not getattr(self, 'labels', None):
self.invalid_syntax('%s %s requires at least one label' %
(self.msg_topic,