Load values from StatusCode.csv and then add values from StatusCodes_add.csv, but only if they are absent from StatusCode.csv
()
| 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 4 | |
| 5 | def 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 | |
| 27 | if __name__ == "__main__": |
no test coverage detected