Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | import json |
| 2 | import sys |
| 3 | |
| 4 | dict = {} |
| 5 | dupliacteUid = {} |
| 6 | #debugFlag = True |
| 7 | debugFlag = False |
| 8 | |
| 9 | def debug(str1, str2=""): |
| 10 | 'print only if debug enabled' |
| 11 | if (debugFlag == True): print str1, str2 |
| 12 | |
| 13 | print 'Number of arguments:', len(sys.argv), 'arguments.' |
| 14 | |
| 15 | |
| 16 | with open(sys.argv[1]) as json_file: |
| 17 | json_data = json.load(json_file) |
| 18 | for x in json_data['vertices']: |
| 19 | uid = None |
| 20 | nodeLabel=x.get('nodeLabel') |
| 21 | debug(nodeLabel) |
| 22 | if ( nodeLabel == 'user' ): |
| 23 | uid = x['userId'] |
| 24 | elif ( nodeLabel == 'tag' ): |
| 25 | uid = x['name'] |
| 26 | elif ( nodeLabel == None ): |
| 27 | pass |
| 28 | elif ( nodeLabel == 'lockNode' ): |
| 29 | uid = x.get('uid') |
| 30 | else: uid = x['uid'] |
| 31 | |
| 32 | debug(nodeLabel, uid) |
| 33 | |
| 34 | existId = dict.get(uid) |
| 35 | if (existId == None): |
| 36 | dict[uid] = x.get('_id') |
| 37 | else: |
| 38 | dupliacteUid[uid] = existId |
| 39 | |
| 40 | print dupliacteUid |
| 41 | |
| 42 | # with open('data.txt', 'w') as outfile: |
| 43 | # json.dump(json_data, outfile) |
| 44 | |
| 45 | |
| 46 | |
| 47 | # print x['uid'] |