-
Notifications
You must be signed in to change notification settings - Fork 247
Expand file tree
/
Copy pathscrape_for_events.py
More file actions
42 lines (34 loc) · 896 Bytes
/
scrape_for_events.py
File metadata and controls
42 lines (34 loc) · 896 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import numpy as np
import glob
import re
from collections import defaultdict
from pprint import pprint
def mHash_fnv1a(mStr):
np.seterr(over='ignore')
val_32_const = np.uint32(0x811c9dc5)
prime_32_const = np.uint32(0x1000193)
value = val_32_const
for c in mStr:
value = (value ^ np.uint32(ord(c))) * prime_32_const
return value
def get_target_files():
x = glob.glob('**/*.[ch]pp', recursive=True)
return x
def get_event_map():
tgts = get_target_files()
event_names = []
event_map = defaultdict(list)
for f in tgts:
with open(f) as fp:
for line in fp:
m = re.match("\s*DECLARE_\w+\((\w+)\)", line)
if m:
#print(m)
event_names.append(m.group(1))
for evt in event_names:
x = mHash_fnv1a(evt)
event_map[x].append(evt)
pprint(event_map)
return event_map
if __name__ == "__main__":
x = get_event_map()