forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-categories-json
executable file
·43 lines (35 loc) · 1.41 KB
/
generate-categories-json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/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[ 'people_to_categories' ] = CMSSW_L2
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()