Created
October 22, 2020 23:29
-
-
Save AdamZWinter/576d2bf31cccad8a7c9ad9744f67d63d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2.7 | |
import json | |
import glob | |
import copy | |
producers = [] | |
for filename in glob.glob('new/*.json'): | |
fileobj = open(filename, "r") | |
stringContents = fileobj.read() | |
jsonObj = json.loads(stringContents) | |
producers = producers + jsonObj["Producers"] | |
unique = [producers[0]] | |
data = {} | |
data['Producers'] = [] | |
for producer in producers: | |
matches = 0 | |
for element in unique: | |
if producer["addr"] == element["addr"] and producer["port"] == element["port"]: | |
matches = 1 | |
break | |
if matches == 0: | |
data['Producers'].append(producer) | |
new = [producer] | |
unique = unique + new | |
with open('testnext-topology.json', 'w') as outfile: | |
json.dump(data, outfile, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment