code: def preformat_cache(cache, start=None, end=None):
      
      # open cache file
      if isinstance(cache, FILE_LIKE + string_types):
          return read_cache(cache, sort=file_segment,
                            segment=Segment(start, end))
  
      # format existing cache file
      cache = type(cache)(cache)  # copy cache
  
      # sort cache
      try:
          cache.sort(key=file_segment)  # sort
      except ValueError:
          # if this failed, then the sieving will also fail, but lets proceed
          # anyway, since the user didn't actually ask us to do this (but
          # its a very good idea)
          return cache
  
      # sieve cache
      if start is None:  # start time of earliest file
          start = file_segment(cache[0])[0]
      if end is None:  # end time of latest file
          end = file_segment(cache[-1])[-1]
      return sieve(cache, segment=Segment(start, end))
docs: Preprocess a `list` of file paths for reading.
  
      - read the cache from the file (if necessary)
      - sieve the cache to only include data we need
  
      Parameters
      ----------
      cache : `list`, `str`
          List of file paths, or path to a LAL-format cache file on disk.
  
      start : `~gwpy.time.LIGOTimeGPS`, `float`, `str`, optional
          GPS start time of required data, defaults to start of data found;
          any input parseable by `~gwpy.time.to_gps` is fine.
  
      end : `~gwpy.time.LIGOTimeGPS`, `float`, `str`, optional
          GPS end time of required data, defaults to end of data found;
          any input parseable by `~gwpy.time.to_gps` is fine.
  
      Returns
      -------
      modcache : `list`
          A parsed, sieved list of paths based on the input arguments.