Commit aa087480 authored by Mathias Lüdtke's avatar Mathias Lüdtke Committed by oroulet

allow passing Node and ua.NodeId as refs

parent 9a8494f4
......@@ -13,6 +13,17 @@ def _check_results(results, reqlen = 1):
r.check()
def _to_nodeid(nodeid):
if isinstance(nodeid, int):
return ua.TwoByteNodeId(nodeid)
elif isinstance(nodeid, Node):
return nodeid.nodeid
elif isinstance(nodeid, ua.NodeId):
return nodeid
elif type(nodeid) in (str, bytes):
return ua.NodeId.from_string(nodeid)
else:
raise ua.UaError("Could not resolve '{0}' to a type id".format(nodeid))
class Node(object):
"""
......@@ -331,7 +342,7 @@ class Node(object):
"""
desc = ua.BrowseDescription()
desc.BrowseDirection = direction
desc.ReferenceTypeId = ua.TwoByteNodeId(refs)
desc.ReferenceTypeId = _to_nodeid(refs)
desc.IncludeSubtypes = includesubtypes
desc.NodeClassMask = nodeclassmask
desc.ResultMask = ua.BrowseResultMask.All
......
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