本文整理汇总了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)
示例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
示例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
示例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