Skip to content

Commit

Permalink
Merge pull request cms-sw#160 from nclopezo/parse-categories-to-json
Browse files Browse the repository at this point in the history
Added a simple script to generate a json file with the categories
  • Loading branch information
nclopezo committed Oct 17, 2014
2 parents 2aff8b4 + 86f4df2 commit ee60b84
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions generate-categories-json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

from categories import CMSSW_CATEGORIES, CMSSW_L2, CMSSW_L1
import json
# Generates a json file sumarizing the categories, their packages, and conveners
# it asumes that categories.py from https://raw.githubusercontent.com/cms-sw/cms-bot/HEAD/categories.py
# is already downloaded

# ------------------------------------------------------------------------------
# Global Variables
# -----------------------------------------------------------------------------
OUTPUT_FILE = 'categories.json'

# ------------------------------------------------------------------------------
# Start of execution
# -----------------------------------------------------------------------------

all_categories = CMSSW_CATEGORIES.keys()
# schema of categories_to_people:
# {
# "<category>" : [ "<person1>" , "person2" , ... , "personN" ]
# }
categories_to_people = {}

for person in CMSSW_L2.keys():
categories = CMSSW_L2[ person ]
for cat in categories:
if not categories_to_people.get( cat ):
categories_to_people[ cat ] = []
categories_to_people[ cat ].append( person )

print '----------------'
print categories_to_people

output = {}
output[ 'categories_to_people' ] = categories_to_people
output[ 'categories_to_packages' ] = CMSSW_CATEGORIES
output[ 'L1' ] = CMSSW_L1

out_json = open( OUTPUT_FILE , "w" )
json.dump( output , out_json , indent=4 )
out_json.close()

0 comments on commit ee60b84

Please sign in to comment.