D_0909
D_0909

Reputation: 3

Extract Contributors from repo in python by interacting with GITHUB API V3

I am using pygithub3 wrapper to interact with GITHUB API. I am trying to get the list of contributors from a git repo, following is my code:

from pygithub3 import Github    

gh = Github()
s = gh.repos.list_contributors(user='poise',repo='python')
print(s)

output: pygithub3.core.result.smart.Result object at 0x7ff40510ffd0

Upvotes: 0

Views: 834

Answers (1)

FM.Dev
FM.Dev

Reputation: 11

As per pygithub3 documentation list_contributors returns a Result. For you to be able to view the result, you need to consume it using one of the following formats:

  1. Iterating over the result.
  2. With a generator.
  3. As a list

Refer to the documentation for details: (http://pygithub3.readthedocs.org/en/latest/result.html)

The list option is straight forward. Just add .all() when printing the result to get the list of contributors.

from pygithub3 import Github    

gh = Github()
s = gh.repos.list_contributors(user='poise',repo='python')
print(s.all())

Output:

<User (jtimberman)>
<User (coderanger)>
<User (schisamo)>
<User (sethvargo)>
<User (damm)>
<User (guilhem)>
<User (joestump)>
<User (ka2n)>
<User (PrajaktaPurohit)>
<User (nathenharvey)>
<User (someara)>
<User (benjaminws)>
<User (captnswing)>
<User (jjhuff)>
<User (andreacampi)>
<User (rody)>
<User (tk0miya)>
<User (comandrei)>
<User (btm)>
<User (spazm)>
<User (akiernan)>
<User (chr4)>
<User (e100)>
<User (garrypolley)>
<User (kamaradclimber)>
<User (hectcastro)>
<User (hltbra)>
<User (spheromak)>
<User (rgbkrk)>
<User (mal)>
<User (Frick)>
<User (miketheman)>
<User (nathanph)>
<User (paulczar)>
<User (petecheslock)>
<User (dexterous)>
<User (stevendanna)>
<User (viralshah)>
<User (chantra)>
<User (tdcarrol)>

Upvotes: 1

Related Questions