Created
June 3, 2015 15:59
-
-
Save stuartcampbell/7d045a42b9ec2301283f to your computer and use it in GitHub Desktop.
Get a list of milestones from github and deal with paging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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