(string)
| 48 | |
| 49 | |
| 50 | def nodeid_code(string): |
| 51 | l = string.split(";") |
| 52 | identifier = None |
| 53 | namespace = 0 |
| 54 | ntype = None |
| 55 | srv = None |
| 56 | nsu = None |
| 57 | for el in l: |
| 58 | if not el: |
| 59 | continue |
| 60 | k, v = el.split("=", 1) |
| 61 | k = k.strip() |
| 62 | v = v.strip() |
| 63 | if k == "ns": |
| 64 | namespace = v |
| 65 | elif k == "i": |
| 66 | ntype = "NumericNodeId" |
| 67 | identifier = v |
| 68 | elif k == "s": |
| 69 | ntype = "StringNodeId" |
| 70 | identifier = f"'{v}'" |
| 71 | elif k == "g": |
| 72 | ntype = "GuidNodeId" |
| 73 | identifier = f"b'{v}'" |
| 74 | elif k == "b": |
| 75 | ntype = "ByteStringNodeId" |
| 76 | identifier = f"b'{v}'" |
| 77 | elif k == "srv": |
| 78 | srv = v |
| 79 | elif k == "nsu": |
| 80 | nsu = v |
| 81 | if identifier is None: |
| 82 | raise Exception("Could not find identifier in string: " + string) |
| 83 | return f"{ntype}({identifier}, {namespace})" |
| 84 | |
| 85 | |
| 86 | class CodeGenerator: |
no outgoing calls
no test coverage detected