def setAggregationMethod(path, aggregationMethod, xFilesFactor=None):
  """setAggregationMethod(path,aggregationMethod,xFilesFactor=None)

path is a string
aggregationMethod specifies the method to use when propagating data (see ``whisper.aggregationMethods``)
xFilesFactor specifies the fraction of data points in a propagation interval that must have known values for a propagation to occur.  If None, the existing xFilesFactor in path will not be changed
"""
  fh = None
  try:

    fh = open(path,'r+b')
    if LOCK:
      fcntl.flock( fh.fileno(), fcntl.LOCK_EX )

    packedMetadata = fh.read(metadataSize)

    try:
      (aggregationType,maxRetention,xff,archiveCount) = struct.unpack(metadataFormat,packedMetadata)
    except:
      raise CorruptWhisperFile("Unable to read header", fh.name)

    try:
      newAggregationType = struct.pack( longFormat, aggregationMethodToType[aggregationMethod] )
    except KeyError:
      raise InvalidAggregationMethod("Unrecognized aggregation method: %s" %
            aggregationMethod)

    if xFilesFactor is not None:
        #use specified xFilesFactor
        xff = struct.pack( floatFormat, float(xFilesFactor) )
    else:
	#retain old value
        xff = struct.pack( floatFormat, xff )

    #repack the remaining header information
    maxRetention = struct.pack( longFormat, maxRetention )
    archiveCount = struct.pack(longFormat, archiveCount)

    packedMetadata = newAggregationType + maxRetention + xff + archiveCount
    fh.seek(0)
    #fh.write(newAggregationType)
    fh.write(packedMetadata)

    if AUTOFLUSH:
      fh.flush()
      os.fsync(fh.fileno())

      if CACHE_HEADERS and fh.name in __headerCache:
        del __headerCache[fh.name]

  finally:
    if fh:
      fh.close()

  return aggregationTypeToMethod.get(aggregationType, 'average')
dataset/ETHPy150Open brutasse/graphite-api/graphite_api/_vendor/whisper.py/setAggregationMethod/original