Ver código fonte

Wrote function for grabbing list of repository names

David Leonard 10 anos atrás
pai
commit
7952c1b6fa

+ 17 - 0
hackathon_starter/hackathon/scripts/github.py

@@ -13,6 +13,10 @@ import simplejson as json
 API_BASE_URL = 'https://api.github.com/'
 API_USERS_URL = API_BASE_URL + 'users/DrkSephy'
 
+# Endpoint to get statistics in a repository
+# https://api.github.com/repos/DrkSephy/WaterEmblem/stats/contributors
+# https://api.github.com/repos/:user/:repo/stats/contributors
+
 def getUserData():
 	req = requests.get(API_USERS_URL)
 	jsonList = []
@@ -29,7 +33,20 @@ def getUserData():
 		userData['followers'] = data['followers']
 		userData['following'] = data['following']
 	parsedData.append(userData)
+
 	return parsedData
 	
+
+def getUserRepositories():
+	req = requests.get(API_USERS_URL + '/repos')
+	jsonList = []
+	jsonList.append(json.loads(req.content))
+	repositories = []
+	for data in jsonList:
+		for datum in data:
+			repositories.append(datum['name'])
+	
+	return repositories
+
 	
 	

+ 3 - 1
hackathon_starter/hackathon/views.py

@@ -5,7 +5,7 @@ from django.template import RequestContext, loader
 from django.contrib.auth import authenticate, login
 from django.http import HttpResponse, HttpResponseRedirect
 from scripts.steam import gamesPulling, steamIDPulling 
-from scripts.github import getUserData
+from scripts.github import getUserData, getUserRepositories
 
 
 def index(request):
@@ -118,6 +118,8 @@ def steam(request):
 
 def github(request):
     userData = getUserData()
+    repositories = getUserRepositories()
+    print repositories
     return render(request, 'hackathon/github.html', { 'data': userData })
 
 def tumblr(request):