tools/remove_duplicate_includes.py
def WithoutDuplicates(input_lines, include_set, cc_file_name):
  """Checks every input line and sees if we can remove it based on the contents
  of the given include set.

  Returns what the new contents of the file should be.
  """
  output_lines = []
  # When a section of includes are completely removed, we want to remove the
  # trailing empty as well.
  lastCopiedLineWasEmpty = False
  lastLineWasOmitted = False
  for line in input_lines:
      match = INCLUDE_REGEX.search(line)
      if match and match.group(2) in include_set:
        print('Removed ' + match.group(1) + ' from ' + cc_file_name)
        lastLineWasOmitted = True
      elif lastCopiedLineWasEmpty and lastLineWasOmitted and IsEmpty(line):
        print('Removed empty line from ' + cc_file_name)
        lastLineWasOmitted = True
      else:
        lastCopiedLineWasEmpty = IsEmpty(line)
        lastLineWasOmitted = False
        output_lines.append(line)
  return output_lines
Checks every input line and sees if we can remove it based on the contents
  of the given include set.

  Returns what the new contents of the file should be.
  
Checks every input line and sees if we can remove it based on the contents
of the given include set.

Returns what the new contents of the file should be.
Checks every input line and sees if we can remove it based on the contents of the given include set . Returns what the new contents of the file should be .
def WithoutDuplicates(input_lines, include_set, cc_file_name):
  output_lines = []
  lastCopiedLineWasEmpty = False
  lastLineWasOmitted = False
  for line in input_lines:
      match = INCLUDE_REGEX.search(line)
      if match and match.group(2) in include_set:
        print('Removed ' + match.group(1) + ' from ' + cc_file_name)
        lastLineWasOmitted = True
      elif lastCopiedLineWasEmpty and lastLineWasOmitted and IsEmpty(line):
        print('Removed empty line from ' + cc_file_name)
        lastLineWasOmitted = True
      else:
        lastCopiedLineWasEmpty = IsEmpty(line)
        lastLineWasOmitted = False
        output_lines.append(line)
  return output_lines
def WithoutDuplicates ( input_lines , include_set , cc_file_name ) : output_lines = [ ] lastCopiedLineWasEmpty = False lastLineWasOmitted = False for line in input_lines : match = INCLUDE_REGEX . search ( line ) if match and match . group ( 2 ) in include_set : print ( 'Removed ' + match . group ( 1 ) + ' from ' + cc_file_name ) lastLineWasOmitted = True elif lastCopiedLineWasEmpty and lastLineWasOmitted and IsEmpty ( line ) : print ( 'Removed empty line from ' + cc_file_name ) lastLineWasOmitted = True else : lastCopiedLineWasEmpty = IsEmpty ( line ) lastLineWasOmitted = False output_lines . append ( line ) return output_lines
Checks every input line and sees if we can remove it based on the contents
of the given include set.
Checks every input line and sees if we can remove it based on the contents of the given include set .
"""Checks every input line and sees if we can remove it based on the contents
  of the given include set.

  Returns what the new contents of the file should be.
  """ # When a section of includes are completely removed, we want to remove the # trailing empty as well.
input_lines
include_set
cc_file_name