Mercurial > repos > bcclaywell > argo_navis
view venv/lib/python2.7/site-packages/planemo/github_util.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
line wrap: on
line source
""" """ try: import github has_github_lib = True except ImportError: github = None has_github_lib = False NO_GITHUB_DEP_ERROR = ("Cannot use github functionality - " "PyGithub library not available.") def get_github_config(ctx): if "github" not in ctx.global_config: return None global_github_config = ctx.global_config["github"] return GithubConfig(global_github_config) class GithubConfig(object): def __init__(self, config): if not has_github_lib: raise Exception(NO_GITHUB_DEP_ERROR) self._github = github.Github(config["username"], config["password"]) def publish_as_gist_file(ctx, path, name="index"): github_config = get_github_config(ctx) user = github_config._github.get_user() content = open(path, "r").read() content_file = github.InputFileContent(content) gist = user.create_gist(False, {name: content_file}) return gist.files[name].raw_url