def transform_attributes(ctx, param, value):
    attrs = {}
    log.debug('TRANSFORM_ATTRIBUTES [IN]: %r' % (value,))

    # If this is a simple string, make it a list.
    if isinstance(value, basestring):
        value = [value]

    # Flatten the attributes using a set to eliminate any duplicates.
    items = set(value)

    # Prepare the context object for storing attribute actions
    parent = ctx.find_root()
    if not hasattr(parent, '_attributes'):
        parent._attributes = []

    for attr in items:
        key, _, val = attr.partition('=')
        if not key:
            msg = 'Invalid attribute: %s; format should be key=value' % (attr,)
            raise click.UsageError(msg)

        # Cast integers to strings (fix #24)
        if isinstance(val, int):
            val = str(val)

        log.debug(' name = %r', key)
        log.debug('value = %r', val)
        parent._attributes.append((key, val))
        attrs[key] = val

    log.debug('TRANSFORM_ATTRIBUTES [OUT]: %r' % (attrs,))
    return attrs
Callback to turn attributes arguments into a dict.
dataset/ETHPy150Open dropbox/pynsot/pynsot/commands/callbacks.py/transform_attributes