當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。