

def measures(*measurements, **kwargs):
    "Decorator-maker used to declare measurements for phases.\n\n  See the measurements module docstring for examples of usage.\n\n  Args:\n    measurements: Measurement objects to declare, or a string name from which\n        to create a Measurement.\n    kwargs: Keyword arguments to pass to Measurement constructor if we're\n        constructing one.  Note that if kwargs are provided, the length\n        of measurements must be 1, and that value must be a string containing\n        the measurement name.  For valid kwargs, see the definition of the\n        Measurement class.\n\n  Returns:\n    A decorator that declares the measurement(s) for the decorated phase.\n  "

    def _maybe_make(meas):
        'Turn strings into Measurement objects if necessary.'
        if isinstance(meas, Measurement):
            return meas
        elif isinstance(meas, basestring):
            return Measurement(meas, **kwargs)
        raise InvalidMeasurementType('Expected Measurement or string', meas)
    if (kwargs and (len(measurements) != 1)):
        raise InvalidMeasurementType('If @measures kwargs are provided, a single measurement name must be provided as a positional arg first.')
    if ('outcome' in measurements):
        raise ValueError('Cannot specify outcome in measurement declaration!')
    measurements = [_maybe_make(meas) for meas in measurements]

    def decorate(wrapped_phase):
        'Phase decorator to be returned.'
        phase = openhtf.PhaseInfo.WrapOrCopy(wrapped_phase)
        duplicate_names = (set((m.name for m in measurements)) & set((m.name for m in phase.measurements)))
        if duplicate_names:
            raise DuplicateNameError('Measurement names duplicated', duplicate_names)
        phase.measurements.extend(measurements)
        return phase
    return decorate

dataset/ETHPy150Open google/openhtf/openhtf/util/measurements.py measures/VarMisuse@97/406 `kwargs`->`measurements`