def parse_volgroup(rule):
 parser = argparse.ArgumentParser()
 rules = shlex.split(rule)
 rules.pop(0)
 partitions = []
 newrules = []
 for count in range(0, len(rules)):
  if (count == 0):
   newrules.append(rules[count])
   continue
  elif rules[count].startswith('--'):
   newrules.append(rules[count])
   continue
  else:
   partitions.append(rules[count])
 rules = newrules
 parser.add_argument('name')
 parser.add_argument('--noformat', dest='noformat', action='store_true')
 parser.add_argument('--useexisting', dest='useexisting', action='store_true')
 parser.add_argument('--pesize', dest='pesize', action='store')
 parser.add_argument('--reserved-space', dest='reserved-space', action='store')
 parser.add_argument('--reserved-percent', dest='reserved-percent', action='store')
 args = clean_args(vars(parser.parse_args(rules)))
 if partitions:
  args['partitions'] = partitions
 parser = None
 return args

def parse_volgroup ( rule ) : parser = argparse . ArgumentParser ( ) rules = shlex . split ( rule ) rules . pop ( 0 ) partitions = [ ] newrules = [ ] for count in range ( 0 , len ( rules ) ) : if ( count == 0 ) : newrules . append ( rules [ count ] ) continue elif rules [ count ] . startswith ( '--' ) : newrules . append ( rules [ count ] ) continue else : partitions . append ( rules [ count ] ) rules = newrules parser . add_argument ( 'name' ) parser . add_argument ( '--noformat' , dest = 'noformat' , action = 'store_true' ) parser . add_argument ( '--useexisting' , dest = 'useexisting' , action = 'store_true' ) parser . add_argument ( '--pesize' , dest = 'pesize' , action = 'store' ) parser . add_argument ( '--reserved-space' , dest = 'reserved-space' , action = 'store' ) parser . add_argument ( '--reserved-percent' , dest = 'reserved-percent' , action = 'store' ) args = clean_args ( vars ( parser . parse_args ( rules ) ) ) if partitions : args [ 'partitions' ] = partitions parser = None return args
parse the volgroup line .