Skip to content

Instantly share code, notes, and snippets.

@notartom
Created April 29, 2018 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notartom/0819df7c3cb9d02315bfabe5630385c9 to your computer and use it in GitHub Desktop.
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)
#!/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