Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (22 sloc) 829 Bytes
# Reads the Networkmanager headers and spits out the enums as a series of
# python variables.
import re
enum_regex = re.compile(r'typedef enum(?:\s+[a-zA-Z]+)?\s*\{(.*?)\}', re.DOTALL)
comment_regex = re.compile(r'/\*.*?\*/', re.DOTALL)
headers = ['/usr/include/NetworkManager/NetworkManager.h',
for h in headers:
for enum in enum_regex.findall(open(h).read()):
enum = comment_regex.sub('', enum)
last = -1
for key in enum.split(','):
if not key.strip():
if '=' in key:
key, val = key.split('=')
val = eval(val)
val = last + 1
key = key.strip()
print '%s = %d' % (key, val)
last = val