summaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/resources/scripts/python/duplicates.py
blob: 7228677734aa782f4917476509a954892ece79c2 (plain)
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
42
43
44
45
46
47
48
49
import json
import sys

dict = {}
dupliacteUid = {}
# debugFlag = True
debugFlag = False


def debug(str1, str2=""):
    'print only if debug enabled'
    if debugFlag:
        print(str1, str2)


print('Number of arguments:', len(sys.argv), 'arguments.')

with open(sys.argv[1]) as json_file:
    json_data = json.load(json_file)
    for x in json_data['vertices']:
        uid = None
        nodeLabel = x.get('nodeLabel')
        debug(nodeLabel)
        if nodeLabel == 'user':
            uid = x['userId']
        elif nodeLabel == 'tag':
            uid = x['name']
        elif nodeLabel is None:
            pass
        elif nodeLabel == 'lockNode':
            uid = x.get('uid')
        else:
            uid = x['uid']

        debug(nodeLabel, uid)

        existId = dict.get(uid)
        if existId == None:
            dict[uid] = x.get('_id')
        else:
            dupliacteUid[uid] = existId

    print(dupliacteUid)

#    with open('data.txt', 'w') as outfile:
#        json.dump(json_data, outfile)


#	print x['uid']