def _add_git_repo(url_builder, username=None, repo=None, module=None, branch=None, commit=None):
'''
Function that creates and adds to the 'sys.meta_path' an HttpImporter object equipped with a URL of a Online Git server.
The 'url_builder' parameter is a function that accepts the username, repo and branch/commit, and creates a HTTP/S URL of a Git server. Compatible functions are '__create_github_url', '__create_bitbucket_url'.
The 'username' parameter defines the Github username which is the repository's owner.
The 'repo' parameter defines the name of the repo that contains the modules/packages to be imported.
The 'module' parameter is optional and is a list containing the modules/packages that are available in the chosen Github repository.
If it is not provided, it defaults to the repositories name, as it is common that the a Python repository at "github.com/someuser/somereponame" contains a module/package of "somereponame".
The 'branch' and 'commit' parameters cannot be both populated at the same call. They specify the branch (last commit) or specific commit, that should be served.
'''
if username == None or repo == None:
raise Error("'username' and 'repo' parameters cannot be None")
if commit and branch:
raise Error("'branch' and 'commit' parameters cannot be both set!")
if commit:
branch = commit
if not branch:
branch = 'master'
if not module:
module = repo
if type(module) == str:
module = [module]
url = url_builder(username, repo, branch)
return add_remote_repo(module, url)
评论列表
文章目录