2

The code below will list all my repos. But is there any way to add 3 more columns to include the creation date, language and type (for e.g. Sources / Forks)? I'm using the PyGithub package.

from github import Github
g = Github("user_name", "passwd")
for repo in g.get_user().get_repos():
    print(repo.name)
Ray Booysen
  • 28,894
  • 13
  • 84
  • 111
shantanuo
  • 31,689
  • 78
  • 245
  • 403

1 Answers1

5

The Repository class does have (assuming PyGithub/PyGithub)

So you can use those attributes and print them in column, using a format string (Python 2.6+, as seen here)

for repo in g.get_user().get_repos():
    print("{: >20} {: >20} {: >20}  {: >20}".format(repo.name, repo.language, repo.created_at, repo.fork))
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @shantanuo Great! Example at https://github.com/PyGithub/PyGithub/blob/74cd6856de404dc3109360860b712d62458c24eb/tests/Repository.py#L65-L77 – VonC Sep 02 '19 at 04:55
  • When I try this (with my credentials) I get GitHubException 401 "Requires authentication" – ManInMoon Mar 16 '21 at 15:51