-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListNonLicensed.py
More file actions
51 lines (40 loc) · 1.31 KB
/
Copy pathListNonLicensed.py
File metadata and controls
51 lines (40 loc) · 1.31 KB
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
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""
List all non-licensed repos (public and private,
if Oauth key has "repo" permission)
Requires GitHub Oauth login with permissions
"repo:public_repo" or "repo" for private repos.
"""
import argparse
import github.GithubException
import gitbulk as gb
def main(username: str, oauth: str, stem: str):
# %% authentication
sess = gb.session(oauth)
gb.check_api_limit(sess)
# %% get user / organization handle
userorg = gb.user_or_org(sess, username)
# %% prepare to loop over repos
repos = gb.get_repos(userorg)
# filter repos
to_act = (
repo
for repo in repos
if repo.name.startswith(stem)
and repo.name != ".github"
and not repo.fork
and not repo.archived
and repo.owner.login == userorg.login
)
for repo in to_act:
try:
repo.get_license()
except github.GithubException:
print(repo.full_name)
if __name__ == "__main__":
p = argparse.ArgumentParser(description="List all non-licensed repos")
p.add_argument("user", help="GitHub username / organizations")
p.add_argument("oauth", help="Oauth filename")
p.add_argument("-stem", help="list repos with name starting with this string", default="")
P = p.parse_args()
main(P.user, P.oauth, P.stem)