def file_merge(fh_from, fh_to):
  headerFrom = __readHeader(fh_from)
  headerTo = __readHeader(fh_to)

  if headerFrom['archives'] != headerTo['archives']:
    raise NotImplementedError("%s and %s archive configurations are unalike. " \
    "Resize the input before merging" % (fh_from.name, fh_to.name))

  archives = headerFrom['archives']
  archives.sort(key=operator.itemgetter('retention'))

  now = int(time.time())
  untilTime = now
  for archive in archives:
    fromTime = now - archive['retention']
    (timeInfo, values) = __archive_fetch(fh_from, archive, fromTime, untilTime)
    (start, end, archive_step) = timeInfo
    pointsToWrite = list(ifilter(
      lambda points: points[1] is not None,
      izip(xrange(start, end, archive_step), values)))
    __archive_update_many(fh_to, headerTo, archive, pointsToWrite)
    untilTime = fromTime
  fh_from.close()
  fh_to.close()
dataset/ETHPy150Open brutasse/graphite-api/graphite_api/_vendor/whisper.py/file_merge/original