files moved and renamed
This commit is contained in:
parent
38592e254b
commit
14590d2eee
|
@ -123,31 +123,60 @@ The theme itself is licensed under a \href{http://creativecommons.org/licenses/b
|
||||||
|
|
||||||
\section{Contributors}
|
\section{Contributors}
|
||||||
\begin{pycode}
|
\begin{pycode}
|
||||||
import httplib
|
import sys
|
||||||
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
URL = 'api.github.com'
|
LOGIN = None
|
||||||
REQ = '/repos/matze/mtheme/contributors'
|
try:
|
||||||
USER_AGENT = ("curl/7.13.2 " +
|
with open('../login.json', 'r') as f:
|
||||||
"(i386-pc-linux-gnu) " +
|
login_data = json.load(f)
|
||||||
"libcurl/7.13.2 " +
|
if (login_data['user'] and login_data['password']):
|
||||||
"OpenSSL/0.9.7e" +
|
LOGIN = (login_data['user'],
|
||||||
"zlib/1.2.2" +
|
login_data['password'])
|
||||||
"libidn/0.5.13")
|
except:
|
||||||
HEADERS = {"User-Agent": USER_AGENT}
|
print("Couldn't load login data.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
conn = httplib.HTTPSConnection(URL)
|
|
||||||
conn.request('GET', REQ, None, HEADERS)
|
|
||||||
resp = conn.getresponse()
|
|
||||||
|
|
||||||
print('\\begin{itemize}')
|
def apiRequestLeft():
|
||||||
if resp.status == 200:
|
resp = requests.get('https://api.github.com/rate_limit',
|
||||||
data = json.loads(resp.read())
|
auth=LOGIN)
|
||||||
for name, url in ((c['login'], c['html_url']) for c in data):
|
if(resp.ok):
|
||||||
print(" \\item \\href{%s}{%s}" % (url, name))
|
data = json.loads(resp.content)
|
||||||
|
return data['rate']['remaining']
|
||||||
else:
|
else:
|
||||||
print(" \\item Couldn't get contributors")
|
return 0
|
||||||
print('\\end{itemize}')
|
|
||||||
|
if not (apiRequestLeft):
|
||||||
|
print("No API requests left to load contributors list. Do you have " +
|
||||||
|
"saved your login information in 'login.json'?")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
resp = requests.get('https://api.github.com/repos/matze/mtheme/contributors',
|
||||||
|
auth=LOGIN)
|
||||||
|
|
||||||
|
print("\\begin{itemize}")
|
||||||
|
if(resp.ok):
|
||||||
|
data = json.loads(resp.content)
|
||||||
|
extracted_data = ((c['login'], c['html_url'], c['url']) for c in data)
|
||||||
|
for user_name, html_url, url in extracted_data:
|
||||||
|
resp = requests.get(url, auth=LOGIN)
|
||||||
|
if(resp.ok):
|
||||||
|
user_data = json.loads(resp.content)
|
||||||
|
try:
|
||||||
|
name = user_data['name']
|
||||||
|
except:
|
||||||
|
name = ""
|
||||||
|
else:
|
||||||
|
if not (apiRequestLeft):
|
||||||
|
name = "Couldn't load name. API request limit exceeded."
|
||||||
|
else:
|
||||||
|
"Couldn't load name."
|
||||||
|
print(" \\item \\href{%s}{%s} %s" % (html_url, user_name, name))
|
||||||
|
else:
|
||||||
|
print(" \\item Couldn't load contributors.")
|
||||||
|
print("\\end{itemize}")
|
||||||
\end{pycode}
|
\end{pycode}
|
||||||
|
|
||||||
\section{Implementation}
|
\section{Implementation}
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue