本文整理汇总了Python中commit.Commit.deletions方法的典型用法代码示例。如果您正苦于以下问题:Python Commit.deletions方法的具体用法?Python Commit.deletions怎么用?Python Commit.deletions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commit.Commit
的用法示例。
在下文中一共展示了Commit.deletions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_commits
# 需要导入模块: from commit import Commit [as 别名]
# 或者: from commit.Commit import deletions [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