Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. # *Information
  2. # File - GithubRepoDownload.py
  3. # Project - GithubRepoDownload
  4. # Description - the primary file for GithubRepoDownload
  5. # Requirements: PyGithub
  6. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  7. # *Imports
  8. import getpass
  9. import os
  10. import urllib.request
  11. from github import Github
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-
  13. # *Primary Function
  14. def main():
  15. print(os.getcwd())
  16. username = input("Github Username ~ ")
  17. password = getpass.getpass("Github Password ~ ")
  18. ghub = Github(username, password)
  19. for repo in ghub.get_user().get_repos():
  20. if not os.path.exists(os.getcwd() + "\\" + repo.name):
  21. os.makedirs(os.getcwd() + "\\" + repo.name)
  22.  
  23. for branch in repo.get_branches():
  24. download_url = repo.html_url + "/archive/" + branch.name + ".zip"
  25. urllib.request.urlretrieve(download_url, repo.name + "\\" + branch.name + ".zip")
  26.  
  27. if __name__ == '__main__':
  28. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement