def update_attrs(kv, attrs, KVClass, obj):
    to_save = []
    for attr, value in kv.iteritems():
        if not attr and not value:
            continue
        if attrs.filter(key=attr):
            kv = attrs.get(key=attr)
            kv.value = value
            to_save.append(kv)
        else:
            # This kv is new. Let's create it and add it to the
            # to_save list for saving!
            kv = KVClass(key=attr, value=value)
            to_save.append(kv)

    for kv in to_save:
        setattr(kv, 'obj', obj)
        kv.clean()
        kv.save()
:param kv: The KV pairs being added to the object.
dataset/ETHPy150Open mozilla/inventory/core/keyvalue/utils.py/update_attrs