Python/Github
DBS
davanand.bahall at gmail.com
Thu Aug 27 18:21:39 EDT 2015
On Monday, August 24, 2015 at 2:28:39 PM UTC-7, DBS wrote:
> On Monday, August 24, 2015 at 2:16:55 PM UTC-7, Chris Rebert wrote:
> > On Mon, Aug 24, 2015 at 1:14 PM, DBS <davanand.bahall at gmail.com> wrote:
> > > Hello,
> > >
> > > I'm trying to retrieve the number of commits and changed files on all pull requests submitted to a branch.
> > >
> > > The call to get all the pull requests is GET /repos/:owner/:repo/pulls, but it does not return "commits" or "changed_files".
> > >
> > > The call that returns number of commits and changed files is GET /repos/:owner/:repo/pulls/:number.
> > >
> > > Any guidance on how I can modify the call below to include commits and changed files on all pull requests?
> > >
> > > #!/usr/bin/env python
> > > import json
> > > import requests
> > <snip>
> >
> > Have you considered using a GitHub API Python library such as
> > github3.py (https://github.com/sigmavirus24/github3.py ) rather than
> > reinventing the wheel?
> >
> > Cheers,
> > Chris
> > --
> > http://chrisrebert.com
>
> Hello Chris,
>
> No I haven't. I didn't know it existed until now. I'm still in the midst of learning python. I will head over that way and read up on the documentation and give it a try. If I have any questions, I will come back and post :). Thanks again!!
>
> Thanks,
> DBS
On Monday, August 24, 2015 at 2:28:39 PM UTC-7, DBS wrote:
> On Monday, August 24, 2015 at 2:16:55 PM UTC-7, Chris Rebert wrote:
> > On Mon, Aug 24, 2015 at 1:14 PM, DBS <davanand.bahall at gmail.com> wrote:
> > > Hello,
> > >
> > > I'm trying to retrieve the number of commits and changed files on all pull requests submitted to a branch.
> > >
> > > The call to get all the pull requests is GET /repos/:owner/:repo/pulls, but it does not return "commits" or "changed_files".
> > >
> > > The call that returns number of commits and changed files is GET /repos/:owner/:repo/pulls/:number.
> > >
> > > Any guidance on how I can modify the call below to include commits and changed files on all pull requests?
> > >
> > > #!/usr/bin/env python
> > > import json
> > > import requests
> > <snip>
> >
> > Have you considered using a GitHub API Python library such as
> > github3.py (https://github.com/sigmavirus24/github3.py ) rather than
> > reinventing the wheel?
> >
> > Cheers,
> > Chris
> > --
> > http://chrisrebert.com
>
> Hello Chris,
>
> No I haven't. I didn't know it existed until now. I'm still in the midst of learning python. I will head over that way and read up on the documentation and give it a try. If I have any questions, I will come back and post :). Thanks again!!
>
> Thanks,
> DBS
Hello again,
After playing around with the github3.py library, I'm pretty impressed.
I do have another question. If I make the request to list the pull requests in my repo with the code below, I get just the name of the pull request. When I use the native get call exposed by the GitHub API, it returns JSON data that I can iterate through. Any clues on how to return JSON using the library. I've imported the JSON module, but I'm not having any luck in getting JSON returned.
#!/usr/bin/env python
from pygithub3 import Github
import requests
import json
import sys
auth = dict(login="xxxxx",user="xxxxx",token="xxxxxxx",repo="my-repo")
gh = Github(**auth)
pr = gh.pull_requests.list().all()
print pr
More information about the Python-list
mailing list