Created
April 29, 2018 18:31
-
-
Save notartom/0819df7c3cb9d02315bfabe5630385c9 to your computer and use it in GitHub Desktop.
Presents enabled filters in an understandable way (expects a bunch of *.list files in its directory as input)
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 python | |
import glob | |
import operator | |
import os | |
clouds = [] | |
for l in glob.glob('*.list'): | |
with open(l) as f: | |
clouds.append(set([line.rstrip() for line in f.readlines()])) | |
common_filters = set.intersection(*clouds) | |
print('Filters common to all deployments: %s\n' % common_filters) | |
all_filters = set.union(*clouds) | |
filter_count = {} | |
for filter in all_filters: | |
for cloud in clouds: | |
if filter in cloud: | |
if filter not in filter_count: | |
filter_count[filter] = 1 | |
else: | |
filter_count[filter] = filter_count[filter] + 1 | |
print('Filter counts (out of %d deployments):' % len(clouds)) | |
sorted_count = sorted(filter_count.items(), key=operator.itemgetter(1), | |
reverse=True) | |
for filter in sorted_count: | |
print('{0:40} {1}'.format(filter[0], filter[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment