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


Python GitHub.user方法代码示例

本文整理汇总了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
开发者ID:naiyt,项目名称:autogithubbot,代码行数:31,代码来源:parser.py

示例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)
开发者ID:acsalu,项目名称:social-traces,代码行数:28,代码来源:app.py


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