本文整理匯總了Python中github.GitHub.user方法的典型用法代碼示例。如果您正苦於以下問題:Python GitHub.user方法的具體用法?Python GitHub.user怎麽用?Python GitHub.user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.GitHub
的用法示例。
在下文中一共展示了GitHub.user方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _make_message
# 需要導入模塊: from github import GitHub [as 別名]
# 或者: from github.GitHub import user [as 別名]
def _make_message(self, message, user, repo):
github = GitHub()
try:
git_user = github.user(user)
except BadUser:
logging.error("Uh oh! {} doesn't seem to be a valid GitHub user.".format(user))
return False
try:
git_repo = github.repo(user, repo)
except BadRepo:
logging.error("Uh oh! Can't connect to {}'s repo {}.".format(user, repo))
return False
# TODO - this is ugly, setup Jinja or some other templating here instead.
message = """
**[{title}]({url})** - *A {language} repository written by [{author}]({author_url})*
> {description}
{stars} stars, {forks} forks
Clone this repository: `{clone}`
---
[I'm a bot](https://github.com/naiyt/autogithubbot) that posts info about GitHub repositories. [Create your own bot](https://github.com/naiyt/reddit-replier)! (Just be nice about it.)
""".format(title=git_repo.name, url=git_repo.url, language=git_repo.language,
description=git_repo.description, author=git_repo.author,
author_url=git_user.url,
stars=git_repo.stars, forks=git_repo.forks, clone=git_repo.clone_url)
return message
示例2: get_gh_data
# 需要導入模塊: from github import GitHub [as 別名]
# 或者: from github.GitHub import user [as 別名]
def get_gh_data():
gh_access_token = request.cookies.get('gh_access_token')
gh = GitHub(access_token=gh_access_token)
user_id = gh.user().get()['login']
page = 1
events = gh.users(user_id).events().get(page=page)
while True:
page += 1
new_events = gh.users(user_id).events().get(page=page)
if len(new_events) > 0:
events.extend(new_events)
else:
break
created_ats = [e['created_at'][:-1] for e in events]
timestamps = []
for ca in created_ats:
ts = time.strptime(ca, "%Y-%m-%dT%H:%M:%S")
timestamps.append((ts.tm_hour * 60 + ts.tm_min -300)%1440)
print("GH: " + str(len(timestamps)))
return json.dumps(timestamps)