github/get_repo_licenses.py: fix help message

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-03-20 19:50:47 +01:00
parent 9bbc5b6111
commit dba844b9d3
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 8 additions and 4 deletions

View File

@ -15,8 +15,10 @@ def parse_opts():
parser = OptionParser(description=HELP_DESCRIPTION, epilog=HELP_EXAMPLE)
parser.add_option('-o', '--github-orgs', type='string', action="append",
help='Names of organizations to scan.')
parser.add_option('-t', '--github-token', default=os.environ['GH_TOKEN'],
parser.add_option('-T', '--github-token', default=os.environ.get('GH_TOKEN', None),
help='GitHub API token.')
parser.add_option('-t', '--github-repo-type', default='public',
help='GitHub Repository type to list.')
parser.add_option('-d', '--csv-dialect', default='excel',
help='CSV dialect to use when formatting.')
parser.add_option('-c', '--csv', action='store_true',
@ -25,10 +27,12 @@ def parse_opts():
(opts, args) = parser.parse_args()
assert opts.github_orgs, parser.error('No GH orgs provided!')
assert opts.github_token, parser.error('No GH token provided!')
return opts, args
def get_repos(gh, org, no_forks=True):
all_repos = gh.get_user(org).get_repos('public')
def get_repos(gh, org, repo_type='all', no_forks=True):
all_repos = gh.get_user(org).get_repos(repo_type)
for repo in all_repos:
# Don't print the urls for repos that are forks.
@ -44,7 +48,7 @@ def main():
repos = []
for org in opts.github_orgs:
for repo in get_repos(gh, org):
for repo in get_repos(gh, org, repo_type=opts.github_repo_type):
license_obj = repo.raw_data.get('license')
license_name = None
if license_obj is not None: