docs: def _consolidate_repo_sources(sources):
      '''
      Consolidate APT sources.
      '''
      if not isinstance(sources, sourceslist.SourcesList):
          raise TypeError(
              '\'{0}\' not a \'{1}\''.format(
                  type(sources),
                  sourceslist.SourcesList
              )
          )
  
      consolidated = {}
      delete_files = set()
      base_file = sourceslist.SourceEntry('').file
  
      repos = [s for s in sources.list if not s.invalid]
  
      for repo in repos:
          repo.uri = repo.uri.rstrip('/')
          # future lint: disable=blacklisted-function
          key = str((getattr(repo, 'architectures', []),
                     repo.disabled, repo.type, repo.uri, repo.dist))
          # future lint: enable=blacklisted-function
          if key in consolidated:
              combined = consolidated[key]
              combined_comps = set(repo.comps).union(set(combined.comps))
              consolidated[key].comps = list(combined_comps)
          else:
              consolidated[key] = sourceslist.SourceEntry(salt.utils.pkg.deb.strip_uri(repo.line))
  
          if repo.file != base_file:
              delete_files.add(repo.file)
  
      sources.list = list(consolidated.values())
      sources.save()
      for file_ in delete_files:
          try:
              os.remove(file_)
          except OSError:
              pass
      return sources