当前位置: 首页>>代码示例>>Python>>正文


Python github3.py方法代码示例

本文整理汇总了Python中github3.py方法的典型用法代码示例。如果您正苦于以下问题:Python github3.py方法的具体用法?Python github3.py怎么用?Python github3.py使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github3的用法示例。


在下文中一共展示了github3.py方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_github

# 需要导入模块: import github3 [as 别名]
# 或者: from github3 import py [as 别名]
def _get_github(self):
        try:
            import github3
        except ImportError:
            raise Exception("""
            ERROR: github3.py not installed!  Please install via
              pip install boundary-layer[github]
            and try again.""")

        if self.github_url:
            return github3.GitHubEnterprise(
                url=self.github_url,
                username=self.github_username,
                password=self.github_password,
                token=self.github_token)

        return github3.GitHub(
            username=self.github_username,
            password=self.github_password,
            token=self.github_token) 
开发者ID:etsy,项目名称:boundary-layer,代码行数:22,代码来源:file_fetcher.py

示例2: create_session

# 需要导入模块: import github3 [as 别名]
# 或者: from github3 import py [as 别名]
def create_session(token=None):
    """
    Create a github3.py session connected to GitHub.com

    If token is not provided, will attempt to use the GITHUB_API_TOKEN
    environment variable if present.
    """
    if token is None:
        token = os.environ.get("GITHUB_API_TOKEN", None)

    gh_session = github3.login(token=token)

    if gh_session is None:
        raise RuntimeError("Invalid or missing GITHUB_API_TOKEN")

    return gh_session 
开发者ID:LLNL,项目名称:scraper,代码行数:18,代码来源:__init__.py

示例3: create_enterprise_session

# 需要导入模块: import github3 [as 别名]
# 或者: from github3 import py [as 别名]
def create_enterprise_session(url, token=None):
    """
    Create a github3.py session for a GitHub Enterprise instance

    If token is not provided, will attempt to use the GITHUB_API_TOKEN
    environment variable if present.
    """

    gh_session = github3.enterprise_login(url=url, token=token)

    if gh_session is None:
        msg = "Unable to connect to GitHub Enterprise (%s) with provided token."
        raise RuntimeError(msg, url)

    return gh_session 
开发者ID:LLNL,项目名称:scraper,代码行数:17,代码来源:__init__.py

示例4: query_repos

# 需要导入模块: import github3 [as 别名]
# 或者: from github3 import py [as 别名]
def query_repos(gh_session, orgs=None, repos=None, public_only=True):
    """
    Yields GitHub3.py repo objects for provided orgs and repo names

    If orgs and repos are BOTH empty, execute special mode of getting ALL
    repositories from the GitHub Server.

    If public_only is True, will return only those repos that are marked as
    public. Set this to false to return all organizations that the session has
    permissions to access.
    """

    if orgs is None:
        orgs = []
    if repos is None:
        repos = []
    if public_only:
        privacy = "public"
    else:
        privacy = "all"

    _check_api_limits(gh_session, 10)

    for org_name in orgs:
        org = gh_session.organization(org_name)
        num_repos = org.public_repos_count

        _check_api_limits(gh_session, _num_requests_needed(num_repos))

        for repo in org.repositories(type=privacy):
            _check_api_limits(gh_session, 10)
            yield repo

    for repo_name in repos:
        _check_api_limits(gh_session, 10)
        org, name = repo_name.split("/")
        yield gh_session.repository(org, name)

    if not (orgs or repos):
        for repo in gh_session.all_repositories():
            yield repo 
开发者ID:LLNL,项目名称:scraper,代码行数:43,代码来源:__init__.py


注:本文中的github3.py方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。