parameters: (f, files_to_process, flags, cwd)
return_statement: return FixManyFiles(contentful_records, flags)
docstring: Fix the #include and forward-declare lines as directed by f.
  
    Given a file object that has the output of the include_what_you_use
    script, see every file to be edited and edit it, if appropriate.
  
    Arguments:
      f: an iterable object that is the output of include_what_you_use.
      files_to_process: A set of filenames, or None.  If not None, we
         ignore files mentioned in f that are not in files_to_process.
      flags: commandline flags, as parsed by optparse.  The only flag
         we use directly is flags.ignore_re, to indicate files not to
         process; we also pass the flags to other routines.
      cwd: the current working directory, externalized for testing.
  
    Returns:
      The number of files that had to be modified (because they weren't
      already all correct).  In dry_run mode, returns the number of
      files that would have been modified.
docstring_summary: Fix the #include and forward-declare lines as directed by f.
docstring_tokens: Fix the #include and forward - declare lines as directed by f .
function: def ProcessIWYUOutput(f, files_to_process, flags, cwd):
    """Fix the #include and forward-declare lines as directed by f.
  
    Given a file object that has the output of the include_what_you_use
    script, see every file to be edited and edit it, if appropriate.
  
    Arguments:
      f: an iterable object that is the output of include_what_you_use.
      files_to_process: A set of filenames, or None.  If not None, we
         ignore files mentioned in f that are not in files_to_process.
      flags: commandline flags, as parsed by optparse.  The only flag
         we use directly is flags.ignore_re, to indicate files not to
         process; we also pass the flags to other routines.
      cwd: the current working directory, externalized for testing.
  
    Returns:
      The number of files that had to be modified (because they weren't
      already all correct).  In dry_run mode, returns the number of
      files that would have been modified.
    """
    if files_to_process is not None:
      files_to_process = [NormalizeFilePath(cwd, fname)
                          for fname in files_to_process]
  
    # First collect all the iwyu data from stdin.
  
    # Maintain sort order by using OrderedDict instead of dict
    iwyu_output_records = OrderedDict()  # IWYUOutputRecords keyed by filename
    while True:
      iwyu_output_parser = IWYUOutputParser()
      try:
        iwyu_record = iwyu_output_parser.ParseOneRecord(f, flags)
        if not iwyu_record:
          break
      except FixIncludesError as why:
        print('ERROR: %s' % why)
        continue
      filename = NormalizeFilePath(flags.basedir, iwyu_record.filename)
      if files_to_process is not None and filename not in files_to_process:
        print('(skipping %s: not listed on commandline)' % filename)
        continue
      if flags.ignore_re and re.search(flags.ignore_re, filename):
        print('(skipping %s: it matches --ignore_re, which is %s)' % (
            filename, flags.ignore_re))
        continue
      if flags.only_re and not re.search(flags.only_re, filename):
        print('(skipping %s: it does not match --only_re, which is %s)' % (
            filename, flags.only_re))
        continue
  
      if filename in iwyu_output_records:
        iwyu_output_records[filename].Merge(iwyu_record)
      else:
        iwyu_output_records[filename] = iwyu_record
  
    # Now ignore all the files that never had any contentful changes
    # seen for them.  (We have to wait until we're all done, since a .h
    # file may have a contentful change when #included from one .cc
    # file, but not another, and we need to have merged them above.)
    if not flags.update_comments:
      for filename in iwyu_output_records:
        if not iwyu_output_records[filename].HasContentfulChanges():
          print('(skipping %s: iwyu reports no contentful changes)' % filename)
          # Mark that we're skipping this file by setting the record to None
          iwyu_output_records[filename] = None
  
    # Now do all the fixing, and return the number of files modified
    contentful_records = [ior for ior in iwyu_output_records.values() if ior]
    return FixManyFiles(contentful_records, flags)
function_tokens: def ProcessIWYUOutput ( f , files_to_process , flags , cwd ) : if files_to_process is not None : files_to_process = [ NormalizeFilePath ( cwd , fname ) for fname in files_to_process ] # First collect all the iwyu data from stdin. # Maintain sort order by using OrderedDict instead of dict iwyu_output_records = OrderedDict ( ) # IWYUOutputRecords keyed by filename while True : iwyu_output_parser = IWYUOutputParser ( ) try : iwyu_record = iwyu_output_parser . ParseOneRecord ( f , flags ) if not iwyu_record : break except FixIncludesError as why : print ( 'ERROR: %s' % why ) continue filename = NormalizeFilePath ( flags . basedir , iwyu_record . filename ) if files_to_process is not None and filename not in files_to_process : print ( '(skipping %s: not listed on commandline)' % filename ) continue if flags . ignore_re and re . search ( flags . ignore_re , filename ) : print ( '(skipping %s: it matches --ignore_re, which is %s)' % ( filename , flags . ignore_re ) ) continue if flags . only_re and not re . search ( flags . only_re , filename ) : print ( '(skipping %s: it does not match --only_re, which is %s)' % ( filename , flags . only_re ) ) continue if filename in iwyu_output_records : iwyu_output_records [ filename ] . Merge ( iwyu_record ) else : iwyu_output_records [ filename ] = iwyu_record # Now ignore all the files that never had any contentful changes # seen for them.  (We have to wait until we're all done, since a .h # file may have a contentful change when #included from one .cc # file, but not another, and we need to have merged them above.) if not flags . update_comments : for filename in iwyu_output_records : if not iwyu_output_records [ filename ] . HasContentfulChanges ( ) : print ( '(skipping %s: iwyu reports no contentful changes)' % filename ) # Mark that we're skipping this file by setting the record to None iwyu_output_records [ filename ] = None # Now do all the fixing, and return the number of files modified contentful_records = [ ior for ior in iwyu_output_records . values ( ) if ior ] return FixManyFiles ( contentful_records , flags )