moved python script into separate file
This commit is contained in:
parent
ae87c4f445
commit
814896eb18
|
@ -0,0 +1,67 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import sys
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
LOGIN = None
|
||||||
|
try:
|
||||||
|
with open("login.json", "r") as f:
|
||||||
|
login_data = json.load(f)
|
||||||
|
if (login_data['user'] and login_data['password']):
|
||||||
|
LOGIN = (login_data['user'],
|
||||||
|
login_data['password'])
|
||||||
|
except:
|
||||||
|
print("Couldn't open file 'login.json'.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def apiRequestLeft():
|
||||||
|
resp = requests.get("https://api.github.com/rate_limit",
|
||||||
|
auth=LOGIN)
|
||||||
|
if(resp.ok):
|
||||||
|
data = json.loads(resp.content)
|
||||||
|
return data['rate']['remaining']
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if not (apiRequestLeft):
|
||||||
|
print("No API requests left to load contributors list. ")
|
||||||
|
if(LOGIN is None):
|
||||||
|
print ("To get more API requests enter your login data into " +
|
||||||
|
"'login.json'")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
resp = requests.get("https://api.github.com/repos/matze/mtheme/contributors",
|
||||||
|
auth=LOGIN)
|
||||||
|
|
||||||
|
latex_string = "\\begin{itemize}\n"
|
||||||
|
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."
|
||||||
|
latex_string += str(" \\item \\href{%s}{%s} %s\n" % (html_url,
|
||||||
|
user_name,
|
||||||
|
name))
|
||||||
|
else:
|
||||||
|
latex_string += " \\item Couldn't load contributors.\n"
|
||||||
|
latex_string += "\\end{itemize}\n"
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open("contributors.tex", "w") as f:
|
||||||
|
f.write(latex_string)
|
||||||
|
print("Successfully written data to file.")
|
||||||
|
print(latex_string)
|
||||||
|
except IOError:
|
||||||
|
print("Error writing to file.")
|
|
@ -0,0 +1,17 @@
|
||||||
|
\begin{itemize}
|
||||||
|
\item \href{https://github.com/matze}{matze} Matthias Vogelgesang
|
||||||
|
\item \href{https://github.com/rchurchley}{rchurchley} Ross Churchley
|
||||||
|
\item \href{https://github.com/benjamin-weiss}{benjamin-weiss} Benjamin Weiss
|
||||||
|
\item \href{https://github.com/eddelbuettel}{eddelbuettel} Dirk Eddelbuettel
|
||||||
|
\item \href{https://github.com/ronnychevalier}{ronnychevalier} Ronny Chevalier
|
||||||
|
\item \href{https://github.com/jdahm}{jdahm} Johann Dahm
|
||||||
|
\item \href{https://github.com/Schwefelsaeure}{Schwefelsaeure}
|
||||||
|
\item \href{https://github.com/awalterschulze}{awalterschulze} Walter Schulze
|
||||||
|
\item \href{https://github.com/ehahn}{ehahn} Erik Hahn
|
||||||
|
\item \href{https://github.com/ChipmunkMath}{ChipmunkMath}
|
||||||
|
\item \href{https://github.com/timbers}{timbers} Finbarr Timbers
|
||||||
|
\item \href{https://github.com/kdungs}{kdungs} Kevin Dungs
|
||||||
|
\item \href{https://github.com/Leonidas-from-XIV}{Leonidas-from-XIV} Marek Kubica
|
||||||
|
\item \href{https://github.com/0ip}{0ip} Robin Buse
|
||||||
|
\item \href{https://github.com/cuzcomd}{cuzcomd}
|
||||||
|
\end{itemize}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"user": "",
|
||||||
|
"password": ""
|
||||||
|
}
|
59
mtheme.dtx
59
mtheme.dtx
|
@ -26,8 +26,6 @@
|
||||||
\setmonofont{Fira Mono}
|
\setmonofont{Fira Mono}
|
||||||
\defaultfontfeatures{Ligatures=TeX}
|
\defaultfontfeatures{Ligatures=TeX}
|
||||||
|
|
||||||
\usepackage{pythontex}
|
|
||||||
|
|
||||||
\usepackage{enumitem}
|
\usepackage{enumitem}
|
||||||
\setlist[itemize]{noitemsep}
|
\setlist[itemize]{noitemsep}
|
||||||
\setlist[enumerate]{noitemsep}
|
\setlist[enumerate]{noitemsep}
|
||||||
|
@ -122,62 +120,7 @@ To get started with the theme is very simple. The following code shows a minimal
|
||||||
The theme itself is licensed under a \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons Attribution-ShareAlike 4.0 International License}. This means that if you change the theme and re-distribute it, you must retain the copyright notice header and license it under the same CC-BY-SA license. This does not affect the presentation that you create with the theme.
|
The theme itself is licensed under a \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons Attribution-ShareAlike 4.0 International License}. This means that if you change the theme and re-distribute it, you must retain the copyright notice header and license it under the same CC-BY-SA license. This does not affect the presentation that you create with the theme.
|
||||||
|
|
||||||
\section{Contributors}
|
\section{Contributors}
|
||||||
\begin{pycode}
|
\input{contributors}
|
||||||
import sys
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
|
|
||||||
LOGIN = None
|
|
||||||
try:
|
|
||||||
with open('../login.json', 'r') as f:
|
|
||||||
login_data = json.load(f)
|
|
||||||
if (login_data['user'] and login_data['password']):
|
|
||||||
LOGIN = (login_data['user'],
|
|
||||||
login_data['password'])
|
|
||||||
except:
|
|
||||||
print("Couldn't load login data.")
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
def apiRequestLeft():
|
|
||||||
resp = requests.get('https://api.github.com/rate_limit',
|
|
||||||
auth=LOGIN)
|
|
||||||
if(resp.ok):
|
|
||||||
data = json.loads(resp.content)
|
|
||||||
return data['rate']['remaining']
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
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}
|
|
||||||
|
|
||||||
\section{Implementation}
|
\section{Implementation}
|
||||||
\DocInput{beamerthemem.dtx}
|
\DocInput{beamerthemem.dtx}
|
||||||
|
|
Loading…
Reference in New Issue