MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / status_codes

Function status_codes

schemas/generate_statuscode.py:5–24  ·  view source on GitHub ↗

Load values from StatusCode.csv and then add values from StatusCodes_add.csv, but only if they are absent from StatusCode.csv

()

Source from the content-addressed store, hash-verified

3BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4
5def status_codes():
6 """
7 Load values from StatusCode.csv and then
8 add values from StatusCodes_add.csv, but only
9 if they are absent from StatusCode.csv
10 """
11 with open(os.path.join(BASE_DIR, 'schemas', 'StatusCodes_add.csv')) as inputfile:
12 additional = {}
13 for line in inputfile:
14 name, val, doc = line.split(",", 2)
15 additional[int(val, 0)] = (name, val, doc)
16
17 with open(os.path.join(BASE_DIR, 'schemas', 'UA-Nodeset-master', 'Schema', 'StatusCode.csv')) as inputfile:
18 result = []
19 for line in inputfile:
20 name, val, doc = line.split(",", 2)
21 result.append((name, val, doc))
22 additional.pop(int(val, 0), None)
23 add = [additional[k] for k in sorted(additional.keys())]
24 return add + result
25
26
27if __name__ == "__main__":

Callers 2

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected