def read_comments(fobj):
 comments = {'filter': {}, 'comment': {}, 'ignore': [], 'replace': {}}
 for line in fobj:
  if line.startswith('#@'):
   (command, args) = line[2:].split(':', maxsplit=1)
   command = command.strip()
   args = args.strip()
   if (command == 'filter'):
    (pkg, filt) = args.split(' ', maxsplit=1)
    comments['filter'][pkg] = filt
   elif (command == 'comment'):
    (pkg, comment) = args.split(' ', maxsplit=1)
    comments['comment'][pkg] = comment
   elif (command == 'ignore'):
    comments['ignore'] += args.split(', ')
   elif (command == 'replace'):
    (pattern, replacement) = args.split(' ', maxsplit=1)
    comments['replace'][pattern] = replacement
 return comments

def read_comments ( fobj ) : comments = { 'filter' : { } , 'comment' : { } , 'ignore' : [ ] , 'replace' : { } } for line in fobj : if line . startswith ( '#@' ) : ( command , args ) = line [ 2 : ] . split ( ':' , maxsplit = 1 ) command = command . strip ( ) args = args . strip ( ) if ( command == 'filter' ) : ( pkg , filt ) = args . split ( ' ' , maxsplit = 1 ) comments [ 'filter' ] [ pkg ] = filt elif ( command == 'comment' ) : ( pkg , comment ) = args . split ( ' ' , maxsplit = 1 ) comments [ 'comment' ] [ pkg ] = comment elif ( command == 'ignore' ) : comments [ 'ignore' ] += args . split ( ', ' ) elif ( command == 'replace' ) : ( pattern , replacement ) = args . split ( ' ' , maxsplit = 1 ) comments [ 'replace' ] [ pattern ] = replacement return comments
given a worksheet and the xml of its comments file .