Added script to generate milestone using github api

Closes https://github.com/CoolProp/CoolProp/issues/278

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-12-03 21:29:02 -05:00
parent 44a4a4d8b5
commit b06bdba9ec

View File

@@ -0,0 +1,28 @@
from __future__ import print_function
import urllib, json, sys
def generate(milestone):
# Find the milestone number for the given name
milestones_json = json.loads(urllib.urlopen('https://api.github.com/repos/CoolProp/CoolProp/milestones').read())
# Map between name and number
title_to_number_map = {stone['title']: stone['number'] for stone in milestones_json}
# Find the desired number
number = title_to_number_map[milestone]
# Get the issues associated with the milestone
issues = json.loads(urllib.urlopen('https://api.github.com/repos/CoolProp/CoolProp/issues?state=all&milestone='+str(number)).read())
# Make sure all issues are closed in this milestone
for issue in issues:
if issue['state'] != 'closed': raise ValueError('This issue is still open: ' + issue['title'])
rst = '\n'.join(['`#{n:d}<http://github.com/CoolProp/CoolProp/issues/{n:d}>` : {t:s}'.format(n = issue['number'], t = issue['title']) for issue in issues])
if __name__=='__main__':
if len(sys.argv) != 2:
raise ValueError('This script should be called like this: python milestone2rst.py v5')
print(generate(sys.argv[1]))