Skip to content

Commit

Permalink
Completed the option parser boiler plate.
Browse files Browse the repository at this point in the history
  • Loading branch information
axiomsofchoice committed Apr 4, 2011
1 parent eb584b8 commit dba6337
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions nametags.py
Expand Up @@ -4,11 +4,21 @@
Uses the following library
http://www.reportlab.com/apis/reportlab/dev/
Takes arguments:
attendees - the csv file from Eventbrite containing the list of
attendees
qrcodes - the directory containing pre-generated QRcodes
output - the directory into which the PDF file will go
logos - the directory into which contains the SciBarCamb logos
The compiled name tags will be rendered four-up onto an A4 page, output as a PDF
"""

import csv
import itertools
import re, sys, os
import getopt
import Image
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter, A4
Expand Down Expand Up @@ -106,40 +116,42 @@ def processAttendees():

def main():

exit(0)
# When present get options from the command line
try:
opts, args = getopt.getopt(sys.argv[1:], "a:q:o:",
["attendees=", "qrcodes=", "output="])
opts, args = getopt.getopt(sys.argv[1:], "a:q:o:l:",
["attendees=", "qrcodes=", "output=", "logos="])
except getopt.GetoptError, err:
# print help information and exit:
print str(err)
usage()
sys.exit(-1)

# Define the dimensions of the QRcodes required (here we give defaults)
(qrcodeWidth, qrcodeHeight) = (500,500)
# The directory into which we store the QRcodes (again, the default)
outdir = "nametags"
# The name of the CSV file from Eventbrite contain the list of attendees
attendeelist = None
# Number of attendees to take from the list (for testing)
takenum = None
# The directory containing pre-generated QRcodes
qrcodes = "qrcodes"
# The directory containing pre-generated QRcodes
logos = "logos"

for o, a in opts:
if o in ("-a", "--attendees"):
attendeelist = a
elif o in ("-q", "--qrcodes"):
qrcodes = a
elif o in ("-o", "--output"):
outdir = a
elif o in ("-t", "--take"):
takenum = a
elif o in ("-l", "--logos"):
logos = a
else:
assert False, "unhandled option"


# Open the CSV file
attendeeReader = csv.DictReader(open(attendeelist, 'rb'))

exit(0)
# Before running the process, ensure that the output directory exists
if not os.path.exists(outdir):
os.mkdir(outdir)
Expand Down

0 comments on commit dba6337

Please sign in to comment.