-
Notifications
You must be signed in to change notification settings - Fork 0
/
repolist.py
executable file
·40 lines (31 loc) · 971 Bytes
/
repolist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
from sys import argv
from os import getenv
from github import Github
from github.GithubException import *
token = None
username = argv[1] if len(argv) > 1 else None
if not username:
print(f'usage: {argv[0]} username')
exit()
g = Github(token)
try:
user = g.get_user(username)
except UnknownObjectException:
print(f'invalid github username: {username}')
exit()
# get a list of repos - skipping forked ones
repos = [ r for r in user.get_repos() if not r.fork ]
# summary
print(f'Showing {len(repos)} of {user.public_repos} repositories in @{username} ({user.type})')
for repo in repos:
description = repo.description or 'description'
topics = '/'.join(repo.topics) or 'topics'
language = repo.language or 'language'
try:
license = repo.get_license().license.name
except:
license = 'license'
print(f'{repo.name:15} {language:10} {license:10} {topics:20}')
print(f'{description} - {repo.html_url}')
print('')