Migrate Python 2 files to Python 3
[sdc.git] / asdctool / src / main / resources / scripts / python / duplicates.py
1 import json
2 import sys
3
4 dict = {}
5 dupliacteUid = {}
6 # debugFlag = True
7 debugFlag = False
8
9
10 def debug(str1, str2=""):
11     'print only if debug enabled'
12     if debugFlag:
13         print(str1, str2)
14
15
16 print('Number of arguments:', len(sys.argv), 'arguments.')
17
18 with open(sys.argv[1]) as json_file:
19     json_data = json.load(json_file)
20     for x in json_data['vertices']:
21         uid = None
22         nodeLabel = x.get('nodeLabel')
23         debug(nodeLabel)
24         if nodeLabel == 'user':
25             uid = x['userId']
26         elif nodeLabel == 'tag':
27             uid = x['name']
28         elif nodeLabel is None:
29             pass
30         elif nodeLabel == 'lockNode':
31             uid = x.get('uid')
32         else:
33             uid = x['uid']
34
35         debug(nodeLabel, uid)
36
37         existId = dict.get(uid)
38         if existId == None:
39             dict[uid] = x.get('_id')
40         else:
41             dupliacteUid[uid] = existId
42
43     print(dupliacteUid)
44
45 #    with open('data.txt', 'w') as outfile:
46 #        json.dump(json_data, outfile)
47
48
49 #       print x['uid']