forked from seveas/python-networkmanager
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakeconstants.py
More file actions
Latest commit
26 lines (23 loc) · 898 Bytes
/
Copy pathmakeconstants.py
File metadata and controls
26 lines (23 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Reads the Networkmanager headers and spits out the enums as a series of
# python variables.
importre
enum_regex=re.compile(r'typedef enum(?:\s+[a-zA-Z]+)?\s*\{(.*?)\}', re.DOTALL)
comment_regex=re.compile(r'/\*.*?\*/', re.DOTALL)
headers= [ '/usr/include/libnm/nm-dbus-interface.h',
'/usr/include/NetworkManager/NetworkManagerVPN.h',
'/usr/include/libnm-glib/nm-secret-agent.h']
forhinheaders:
forenuminenum_regex.findall(open(h).read()):
enum=comment_regex.sub('', enum)
last=-1
forkeyinenum.split(','):
ifnotkey.strip():
continue
if'='inkey:
key, val=key.split('=')
val=eval(val.replace('LL',''))
else:
val=last+1
key=key.strip()
print('%s = %d'% (key, val))
last=val