Commit d000d3d1 authored by Peter V. Saveliev's avatar Peter V. Saveliev

ndb.objects: update `set()` syntax

Valid variants::
	br0.set('mtu', 1500)
	br0.set(mtu=1500)
parent d5d2ad58
......@@ -376,7 +376,7 @@ class RTNL_Object(dict):
out[key] = self[key]
return '%s\n' % json.dumps(out, indent=4, separators=(',', ': '))
def set(self, key, value):
def set(self, *argv, **kwarg):
'''
Set a field specified by `key` to `value`, and return self. The
method is useful to write call chains like that::
......@@ -388,6 +388,12 @@ class RTNL_Object(dict):
.set('address', '00:11:22:33:44:55')
.commit())
'''
key, value = None, None
if argv:
key, value = argv
elif kwarg:
for key, value in kwarg.items():
break
self[key] = value
return self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment