def ProcessCommandFlags(args):
 flags = {}
 rkeyval = '--(?P<key>\\S*)[=](?P<value>\\S*)'
 roption = '--(?P<option>\\S*)'
 r = (((('(' + rkeyval) + ')|(') + roption) + ')')
 rc = re.compile(r)
 for a in args:
  try:
   rcg = rc.search(a).groupdict()
   if rcg.has_key('key'):
    flags[rcg['key']] = rcg['value']
   if rcg.has_key('option'):
    flags[rcg['option']] = rcg['option']
  except AttributeError:
   return None
 return flags

def ProcessCommandFlags ( args ) : flags = { } rkeyval = '--(?P<key>\\S*)[=](?P<value>\\S*)' roption = '--(?P<option>\\S*)' r = ( ( ( ( '(' + rkeyval ) + ')|(' ) + roption ) + ')' ) rc = re . compile ( r ) for a in args : try : rcg = rc . search ( a ) . groupdict ( ) if rcg . has_key ( 'key' ) : flags [ rcg [ 'key' ] ] = rcg [ 'value' ] if rcg . has_key ( 'option' ) : flags [ rcg [ 'option' ] ] = rcg [ 'option' ] except AttributeError : return None return flags
parse command line flags per specified usage .