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


Python Commit.timestamp方法代码示例

本文整理汇总了Python中commit.Commit.timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python Commit.timestamp方法的具体用法?Python Commit.timestamp怎么用?Python Commit.timestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在commit.Commit的用法示例。


在下文中一共展示了Commit.timestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_commits

# 需要导入模块: from commit import Commit [as 别名]
# 或者: from commit.Commit import timestamp [as 别名]
def get_commits(github_user, fetch=False, write_to_file=False):
    password = get_password(github_user)
    if fetch:
        base_url = "https://api.github.com"
        events_url_tail = '/users/'+github_user+'/events'
        response = requests.get(base_url + events_url_tail, auth=(github_user, password))
        events = response.content
        if write_to_file:
            with open('akaptur_events.txt', 'w') as f:
                f.write(events)
        # events = json.load(events) # probably doesn't work
    else:
        with open('akaptur_events.txt') as f:
            events = json.load(f)

    my_commits = []
    print "Total events:", len(events)
    for event in events[:10]:
        print "Event type:", event['type']
        pdb.set_trace()
        if event['type'] == "PushEvent":
            commits = event['payload']['commits']
            print len(commits)
            for comm in commits:
                c = Commit()
                c.url = comm['url']
                # per-event API call :(
                commit_response = requests.get(c.url, auth=(github_user, password))
                commit_data = json.loads(commit_response.content)
                c.additions = commit_data['stats']['additions']
                c.deletions = commit_data['stats']['deletions']
                c.timestamp = commit_data['commit']['author']['date']
                c.message = commit_data['commit']['message']
                my_commits.append(c)
                

    return my_commits
开发者ID:akaptur,项目名称:stats,代码行数:39,代码来源:stats.py


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