return r
-def walk_defs(s, is_message = False):
+def walk_defs(s, is_message=False):
r = []
for t in s:
d = []
d.append(t.name)
for b in t.block:
+ if b.type == 'Option':
+ continue
if b.type == 'Field':
if b.limit:
d.append([b.fieldtype, b.fieldname, b.limit])
d.append([b.fieldtype, b.fieldname])
elif b.type == 'Array':
if b.lengthfield:
- d.append([b.fieldtype, b.fieldname, b.length, b.lengthfield])
+ d.append([b.fieldtype, b.fieldname,
+ b.length, b.lengthfield])
else:
d.append([b.fieldtype, b.fieldname, b.length])
elif b.type == 'Union':
def run(filename, s):
j = {}
- j['types'] = walk_defs([o for o in s['types'] if o.__class__.__name__ == 'Typedef'])
+ j['types'] = (walk_defs([o for o in s['types']
+ if o.__class__.__name__ == 'Typedef']))
j['messages'] = walk_defs(s['Define'], True)
- j['unions'] = walk_defs([o for o in s['types'] if o.__class__.__name__ == 'Union'])
- j['enums'] = walk_enums([o for o in s['types'] if o.__class__.__name__ == 'Enum'])
+ j['unions'] = (walk_defs([o for o in s['types']
+ if o.__class__.__name__ == 'Union']))
+ j['enums'] = (walk_enums([o for o in s['types']
+ if o.__class__.__name__ == 'Enum']))
j['services'] = walk_services(s['Service'])
j['options'] = s['Option']
- j['aliases'] = s['Alias']
+ j['aliases'] = {k: v.alias for k, v in s['Alias'].items()}
j['vl_api_version'] = hex(s['file_crc'])
return json.dumps(j, indent=4, separators=(',', ': '))