Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion github.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
with requests.Session() as session:
session.auth = (config.user, config.password)


def get_repos(since=0):
"""
Place Holder Comment
"""
url = 'http://api.github.com/repositories'

data = """{
since: %s
}""" % since
Expand All @@ -25,25 +30,48 @@ def get_repos(since=0):


def get_repo(url):
"""
Returns the array of .json files of the current repository
"""
response = session.get(url)
return response.json()


def get_read_me(url):
# Grabs the readme file associated with the current repository
"""
Returns the repository's readme file
"""
url += '/readme'
response = session.get(url)
return response.json()


# todo: return array of all commits so we can examine each one
def get_repo_sha(url):
"""
Returns the last commit's SHA
"""
# /repos/:owner/:repo/commits
commits = session.get(url + '/commits').json()
return commits[0]['sha']


# todo: This function should return an all of all the Commits
def get_all_repo_sha(url):
"""
Return a list of all commit's SHA
"""
commits = session.get(url + '/commits').json()
all_sha = []
for x in range(len(commits)):
all_sha[x] = commits[x]['sha']
return all_sha


def get_file_content(item):
"""
Place Holder Comment
"""
ignore_extensions = ['jpg']
filename, extension = os.path.splitext(item['path'])
if extension in ignore_extensions:
Expand All @@ -57,6 +85,9 @@ def get_file_content(item):


def get_repo_contents(url, sha):
"""
Place Holder Comment
"""
# /repos/:owner/:repo/git/trees/:sha?recursive=1
url += '/git/trees/%s?recursive=1' % sha
# print 'url', url
Expand Down