From ef9bc880775d203a337f91dca9b3ad4e96a9c4c7 Mon Sep 17 00:00:00 2001 From: Eddog53 Date: Wed, 4 Jan 2017 22:33:28 -0800 Subject: [PATCH 1/2] added get_all_repo_sha(url) Added new function to github.py that will return a list of the SHA for each commit --- github.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/github.py b/github.py index 28bf03d..b75c887 100644 --- a/github.py +++ b/github.py @@ -5,10 +5,14 @@ import config with requests.Session() as session: - session.auth = (config.user, config.password) + session.auth = (config.user, config.password) def get_repos(since=0): + ''' + Place Holder Comment + ''' url = 'http://api.github.com/repositories' + data = """{ since: %s }""" % since @@ -25,11 +29,17 @@ def get_repos(since=0): def get_repo(url): + ''' + Place Holder Comment + ''' response = session.get(url) return response.json() def get_read_me(url): + ''' + Place Holder Comment + ''' # Grabs the readme file associated with the current repository url += '/readme' response = session.get(url) @@ -38,12 +48,29 @@ def get_read_me(url): # todo: return array of all commits so we can examine each one def get_repo_sha(url): + ''' + Place Holder Comment + ''' # /repos/:owner/:repo/commits commits = session.get(url + '/commits').json() return commits[0]['sha'] + def get_all_repo_sha(url): + ''' + Place Holder Comment + ''' + 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: @@ -57,6 +84,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 From 3abb08dd5e97c9707b01dcad6cfe26d0f7abb518 Mon Sep 17 00:00:00 2001 From: Eddog53 Date: Wed, 4 Jan 2017 22:40:44 -0800 Subject: [PATCH 2/2] docstrings placeholders for docstrings --- github.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/github.py b/github.py index b75c887..1cd54ed 100644 --- a/github.py +++ b/github.py @@ -5,12 +5,13 @@ import config 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 = """{ @@ -29,18 +30,17 @@ def get_repos(since=0): def get_repo(url): - ''' - Place Holder Comment - ''' + """ + Returns the array of .json files of the current repository + """ response = session.get(url) return response.json() def get_read_me(url): - ''' - Place Holder Comment - ''' - # Grabs the readme file associated with the current repository + """ + Returns the repository's readme file + """ url += '/readme' response = session.get(url) return response.json() @@ -48,18 +48,19 @@ def get_read_me(url): # todo: return array of all commits so we can examine each one def get_repo_sha(url): - ''' - Place Holder Comment - ''' + """ + 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): - ''' - Place Holder Comment - ''' + """ + Return a list of all commit's SHA + """ commits = session.get(url + '/commits').json() all_sha = [] for x in range(len(commits)): @@ -68,9 +69,9 @@ def get_all_repo_sha(url): def get_file_content(item): - ''' + """ Place Holder Comment - ''' + """ ignore_extensions = ['jpg'] filename, extension = os.path.splitext(item['path']) if extension in ignore_extensions: @@ -84,9 +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