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