mirror of
https://github.com/synthetos/g2.git
synced 2026-10-06 22:52:49 +08:00
17 lines
500 B
Python
17 lines
500 B
Python
import re
|
|
import json
|
|
|
|
codes = {}
|
|
with open('../TinyG2/tinyg2.h') as fp:
|
|
for line in fp.readlines():
|
|
match = re.match('\s*#define\s*(\w+)\s*([0-9]+)\s*(?://([\w\s]*))?', line)
|
|
if match:
|
|
name, value, description = match.groups()
|
|
description = description.strip() if description else ''
|
|
codes[value] = (name, description)
|
|
|
|
with open('g2_errors.json', 'w') as fp:
|
|
json.dump(codes, fp, indent=3)
|
|
|
|
print 'Error codes written to g2_errors.json.'
|