Package: githubdl
Github Path DownloaderA tool for downloading individual files/directories from Github or Github Enterprise.This circumvents the requirement to clone a complete repository.Requirements:Python 3.4+A Github or Github Enterprise AccountInstallation:pip:$pipinstallgithubdlhttp:$pipinstallgit+https://github.com/wilvk/githubdl.gitssh:$pipinstallgit+ssh://git@github.com:wilvk/githubdl.gitfrom clone:$gitclonegit@github.com:wilvk/githubdl.git
$cdgithubdl
$pipinstall-e.Usage:Obtaining a Github token:You will need a token from either Github Enterprise or Github as this package works with the Github v3 API.To do this:Log into your Github accountClick the Avatar Menu in the top-right corner, and selectSettingsOn the Settings page, from the menu on the left-hand side, selectDeveloper SettingsFrom the Developer Settings page, from the menu, selectPersonal access tokensClick theGenerate new tokenbuttonEnter a name for the token. The token should only require theread:orgpermission specified.There are also instructions on how to do thishere.Usage (from the commandline):With your new Github token, export it as the environment variableGIT_TOKEN.On Unix/Linux:$exportGIT_TOKEN=1234567890123456789012345678901234567890123On Windows:C:\> set GIT_TOKEN=1234567890123456789012345678901234567890123Single file:Then, for example, to download a file calledREADME.mdfrom the repositoryhttp://github.com/wilvk/pbec:$githubdl-u"http://github.com/wilvk/pbec"-f"README.md"2018-05-1207:19:16,934-root-INFO-Requestingfile:README.mdaturl:https://api.github.com/repos/wilvk/pbec/contents/README.md2018-05-1207:19:18,165-root-INFO-Writingtofile:README.mdEntire directory:$githubdl-u"http://github.com/wilvk/pbec"-d"support"2018-05-1207:19:41,667-root-INFO-Retrievingalistoffilesfordirectory:support2018-05-1207:19:41,668-root-INFO-Requestingfile:supportaturl:https://api.github.com/repos/wilvk/pbec/contents/support2018-05-1207:19:42,978-root-INFO-Requestingfile:support/ScreenShot2017-12-10at9.27.56pm.pngaturl:https://api.github.com/repos/wilvk/pbec/contents/support/ScreenShot2017-12-10at9.27.56pm.png2018-05-1207:19:46,274-root-INFO-Writingtofile:support/ScreenShot2017-12-10at9.27.56pm.png2018-05-1207:19:46,286-root-INFO-Retrievingalistoffilesfordirectory:support/docker
...Entire repository:$githubdl-u"http://github.com/wilvk/pbec"-d"/"-t"."...Note: if-tis not set, output will go to your/directory.By commit hash:Single file from a specific commit:$githubdl-u"http://github.com/wilvk/pbec"-f"README.md"-r"c29eb5a5d364870a55c0c22f203f8c4e2ce1c638"...Entire directory from a specific commit:$githubdl-u"http://github.com/wilvk/pbec"-d"support"-r"c29eb5a5d364870a55c0c22f203f8c4e2ce1c638"...Entire repository from a specific commit:$githubdl-u"http://github.com/wilvk/pbec"-d"/"-r"c29eb5a5d364870a55c0c22f203f8c4e2ce1c638"-t"."...Note: if-tis not set, output will go to your/directory.Entire repository from a specific commit, with submodules (as specified in .gitmodules):$githubdl-u"http://github.com/wilvk/pbec"-d"/"-r"c29eb5a5d364870a55c0c22f203f8c4e2ce1c638"-t"."-s

...List all tags for a repository in JSON:$githubdl-u"http://github.com/wilvk/pbec"-aList all branches for a repository in JSON:$githubdl-u"http://github.com/wilvk/pbec"-bOptions:Current options are:$githubdl--helpor-h--file-f--dir-d--url(required)-u--target-t--git_token-g--log_level-l--reference-r--tags-a--branches-b--submodules-sLogging:Valid log levels are:DEBUG,INFO,WARN,ERROR,CRITICALReferences:References can be applied to file and directory download only and consist of valid:repository tagscommit SHAsbranch names.Usage (as a package):Loading the package (in a REPL):$ python
Python 3.4.8 (default, Feb  7 2018, 02:31:08)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import githubdlDownloading a directory:Passing in a token:>>>githubdl.dl_dir("https://github.com/wilvk/pbec","support",github_token="1234567890123456789012345678901234567890123")Token as an environment variable:In bash:$exportGIT_TOKEN=1234567890123456789012345678901234567890123In Python:>>>githubdl.dl_dir("https://github.com/wilvk/pbec","support")Saving to a different path:>>>githubdl.dl_dir("https://github.com/wilvk/pbec","support","support_new")Saving to a different path with submodules:>>>githubdl.dl_dir("https://github.com/wilvk/pbec","support","support_new",submodules=True)Downloading a file:Passing in a token:>>>githubdl.dl_file("https://github.com/wilvk/pbec","README.md",github_token="1234567890123456789012345678901234567890123")Token as an environment variable:In bash:$exportGIT_TOKEN=1234567890123456789012345678901234567890123In Python:>>>githubdl.dl_file("https://github.com/wilvk/pbec","README.md")Saving with a different filename:>>>githubdl.dl_file("https://github.com/wilvk/pbec","README.md","NEW_README.md")Extended options:File download options:Onlyrepo_urlandfile_nameare required.defdl_file(repo_url,file_name,target_filename='',github_token='',log_level='',reference=''):Directory download options:Onlyrepo_urlandbase_pathare required.defdl_dir(repo_url,base_path,target_path='',github_token='',log_level='',reference='',submodules=''):Tags download options:Onlyrepo_urlis required.defdl_tags(repo_url,github_token='',log_level=''):Branches download options:Onlyrepo_urlis required.defdl_branches(repo_url,github_token='',log_level=''):A note on logging:Log level is passed in asloggingvariable. e.g.>>>importlogging>>>importgithubdl>>>githubdl.dl_file("http://github.com/wilvk/pbec","README.md",log_level=logging.DEBUG)Tests:$auto/run-testsNote: You will have to have a Github token exported asGIT_TOKENto run the tests.