Skip to content

Commit

Permalink
Adds script to generate badges
Browse files Browse the repository at this point in the history
  • Loading branch information
EiffL committed Feb 20, 2019
1 parent 7273fa5 commit 41d458f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,6 @@ TSWLatexianTemp*

# KBibTeX
*~[0-9]*

db_secret
latex/*
59 changes: 59 additions & 0 deletions badges_from_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env
from sqlalchemy import *
from io import open
from string import Template

with open('db_secret', encoding="utf-8") as f:
DATABASE_URL = f.read()

db = create_engine(DATABASE_URL)

# Last name of locals
list_of_locals = ['Kirk', 'McCoy']
list_of_locals = [n.lower() for n in list_of_locals]

# Last name of contact persons
list_of_contacts = ['Spock', 'Kirk']
list_of_contacts = [n.lower() for n in list_of_contacts]

# Email of people who have used the wrong slot for their last name
list_of_inverse_behavior = ['[email protected]']

sql_query = "select lname, sname, first_name, last_name, affiliation, pronoun, email from participants"
temp = Template('\participant{ $lname }{ $sname }{ $affiliation }{ $pronoun }{ $highlight }\n')

with open('latex/participants.tex', 'w', encoding="utf-8")as f:
for lname, sname, first_name, last_name, affiliation, pronoun, email in db.engine.execute(sql_query).fetchall():

# Defaulting for people who did not provide a preference
if email in list_of_inverse_behavior:
if lname == '':
lname = first_name
if sname == '':
sname = last_name
else:
if lname == '' and sname == '':
lname = first_name
sname = last_name

# Removing pronoun if blank space provided
if len(pronoun) < 2:
print('Warning, setting %s pronoun to empty'%pronoun)
pronoun = ''

# if in the list of locals, add flag
if last_name.lower() in list_of_contacts:
highlight = '\\contact'
elif last_name.lower() in list_of_locals:
highlight = '\\local'
else:
highlight = ''

s = temp.substitute(lname=lname, sname=sname, affiliation=affiliation,
pronoun=pronoun, highlight=highlight)

# Escaping problematic characters
s = s.replace('&', '\&')
#s = s.replace('@', '\@')
s = s.replace('_', '\_')
f.write(s)
Empty file added config.yml
Empty file.
4 changes: 2 additions & 2 deletions latex/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
\hyphenpenalty=10000

%% essential packages
\usepackage[boxed]{ticket} %when ready to print, remove the "boxed" option
\usepackage{ticket} %when ready to print, remove the "boxed" option
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx} % provides \includegraphics
\usepackage{adjustbox} % provides \maxsizebox
Expand Down Expand Up @@ -62,7 +62,7 @@
\newcommand*{\emptyticket}{\ticket{}}

%% local people or other highlight commands
\newcommand*{\local}{\highlight{Dandelion}}
\newcommand*{\local}{\highlight{orange}}
\newcommand*{\contact}{\highlight{CornflowerBlue}}


Expand Down

0 comments on commit 41d458f

Please sign in to comment.