Moved node_setattr() to pillar.api.utils.

This commit is contained in:
2016-11-09 12:49:48 +01:00
parent c4b9564398
commit 2bb332c58a
2 changed files with 2 additions and 75 deletions

View File

@@ -6,7 +6,7 @@ import logging
import attr
import flask
import flask_login
from bson import ObjectId
from eve.methods.put import put_internal
from werkzeug import exceptions as wz_exceptions
@@ -14,6 +14,7 @@ import pillarsdk
import pillar.api.utils
from pillar.web.system_util import pillar_api
from pillar.api.nodes.custom import register_patch_handler
from pillar.api.utils import node_setattr
from pillar import attrs_extra
from attract.node_types import node_type_shot, node_type_task
@@ -206,23 +207,6 @@ class ShotManager(object):
return summary
def node_setattr(node, key, value):
"""Sets a node property by dotted key.
Modifies the node in-place. Deletes None values.
"""
set_on = node
while key and '.' in key:
head, key = key.split('.', 1)
set_on = set_on[head]
if value is None:
set_on.pop(key, None)
else:
set_on[key] = value
@register_patch_handler(node_type_shot['name'])
def patch_shot(node_id, patch):
assert_is_valid_patch(patch)