Skip to content

Instantly share code, notes, and snippets.

@nickbauman
Last active April 21, 2019 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickbauman/7f773716ce72e527e67e0c960121bd6c to your computer and use it in GitHub Desktop.
Save nickbauman/7f773716ce72e527e67e0c960121bd6c to your computer and use it in GitHub Desktop.
Lists all the repos, pub and priv, of a github user or organization. Prompts for password and/or 2FA token
from github3 import login
# Python 3
prompt = input
if __name__ == '__main__':
if len(sys.argv) > 1:
passwd = prompt('Enter password: ')
twofa = prompt('Enter 2FA code: ')
org = sys.argv[1]
gh = login('<your username>', passwd, two_factor_callback=lambda: twofa)
print("looking up repos in '{}'".format(org))
for short_repository in gh.repositories_by(org):
if short_repository.fork: # skip non-original repos
continue
print(short_repository.url)
else:
print("supply argument for organization or username")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment