Skip to content

Instantly share code, notes, and snippets.

@stuartcampbell
Created June 3, 2015 15:59
Show Gist options
  • Select an option

  • Save stuartcampbell/7d045a42b9ec2301283f to your computer and use it in GitHub Desktop.

Select an option

Save stuartcampbell/7d045a42b9ec2301283f to your computer and use it in GitHub Desktop.
Get a list of milestones from github and deal with paging
def get_milestones_from_github():
print('Getting list of all milestones from Github.')
req = requests.get('https://api.github.com/repos/mantidproject/mantid/milestones',
params={'state': 'all'})
# print(r)
_milestones = {}
for milestone in req.json():
# print(milestone)
_milestones[milestone['title']] = milestone['number']
status_code = req.status_code
while status_code == 200:
# we have more pages
try:
req = requests.get(req.links['next']['url'])
# print(r)
# print(r.links)
for milestone in req.json():
_milestones[milestone['title']] = milestone['number']
except:
status_code = 0
print('Found {0} milestones.'.format(len(_milestones)))
return _milestones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment