-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdump_eventflow_names.py
More file actions
33 lines (27 loc) · 852 Bytes
/
dump_eventflow_names.py
File metadata and controls
33 lines (27 loc) · 852 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
import evfl
import mmh3
import json
import os
import sys
seen_actors = {}
def collect_names(path):
ev = evfl.EventFlow()
ev.read(open(path, 'rb').read())
for actor in ev.flowchart.actors:
try:
ac_dict = seen_actors[str(actor.identifier)]
except KeyError:
ac_dict = {'queries': {}, 'actions': {}}
seen_actors[str(actor.identifier)] = ac_dict
for query in actor.queries:
query = str(query)
ac_dict['queries'][query] = mmh3.hash(query.encode('utf-8')) & 0xFFFFFFFF
for action in actor.actions:
action = str(action)
ac_dict['actions'][action] = mmh3.hash(action.encode('utf-8')) & 0xFFFFFFFF
in_path = sys.argv[1]
for name in os.listdir(in_path):
if name.endswith('.bfevfl'):
collect_names(in_path + '/' + name)
with open('eventflow_actor_info.json', 'w') as f:
json.dump(seen_actors, f, indent=4, sort_keys=True)