def from_string(string): if ":" in string: try: idx, name = string.split(":", 1) idx = int(idx) except (TypeError, ValueError) as ex: raise UaStringParsingError("Error parsing string {}".format(string), ex) else: idx = 0 name = string return QualifiedName(name, idx)
def _from_string(string): l = string.split(";") identifier = None namespace = 0 ntype = None srv = None nsu = None for el in l: if not el: continue k, v = el.split("=", 1) k = k.strip() v = v.strip() if k == "ns": namespace = int(v) elif k == "i": ntype = NodeIdType.Numeric identifier = int(v) elif k == "s": ntype = NodeIdType.String identifier = v elif k == "g": ntype = NodeIdType.Guid identifier = v elif k == "b": ntype = NodeIdType.ByteString identifier = v elif k == "srv": srv = v elif k == "nsu": nsu = v if identifier is None: raise UaStringParsingError( "Could not find identifier in string: " + string) nodeid = NodeId(identifier, namespace, ntype) nodeid.NamespaceUri = nsu nodeid.ServerIndex = srv return nodeid
def from_string(string): try: return NodeId._from_string(string) except ValueError as ex: raise UaStringParsingError( "Error parsing string {}".format(string), ex)