added option to generate speaker pdf

This commit is contained in:
Frank Becker 2011-12-27 15:09:00 +01:00
parent a183c63ecc
commit c18589a854
5 changed files with 129 additions and 45 deletions

View File

@ -20,7 +20,7 @@
}
],
"source": "http://de.wikipedia.org/wiki/Strahlenkrankheit",
"tier": 10,
"tier": 1,
"image": "data/pix/q_fukushima.jpg"
},
{
@ -44,7 +44,7 @@
}
],
"source": "http://www.justiz.sachsen.de/smj/content/2674.php Offizielle Pressemitteilung",
"tier": 3,
"tier": 10,
"image": "data/pix/q_bundestrojaner.jpg"
},
{
@ -68,7 +68,7 @@
}
],
"source": "http://www.theregister.co.uk/2010/03/10/cryptome_paypal/",
"tier": 6,
"tier": 4,
"image": "data/pix/q_paypal4.jpg"
},
{
@ -92,7 +92,7 @@
}
],
"source": "http://www.spiegel.de/politik/ausland/0,1518,802967,00.html",
"tier": 7,
"tier": 5,
"image": "data/pix/q_russian.jpg"
},
{
@ -141,7 +141,7 @@
}
],
"source": "http://www.piratenpartei-soest.de/2011/11/das-piraten-abc/",
"tier": 10,
"tier": 4,
"image": "data/pix/q_uhl.jpg"
},
{
@ -165,7 +165,7 @@
}
],
"source": "http://www.h-online.com/security/news/item/Tenth-anniversary-of-the-Convention-on-Cybercrime-1384180.html",
"tier": 9,
"tier": 4,
"image": "data/pix/q_cybercrime.png"
},
{
@ -213,7 +213,7 @@
}
],
"source": "http://www.heise.de/tp/blogs/8/150565",
"tier": 8,
"tier": 2,
"image": "data/pix/q_hadopi.png"
},
{
@ -237,7 +237,7 @@
}
],
"source": "http://www.engadget.com/2011/09/23/scientists-reconstruct-images-from-our-brains-plan-to-do-the-sa/",
"tier": 8,
"tier": 5,
"image": "data/pix/q_brain.png"
},
{
@ -261,7 +261,7 @@
}
],
"source": "http://linux.slashdot.org/story/11/10/05/1920255/welcome-back-kernelorg",
"tier": 4,
"tier": 10,
"image": "data/pix/q_kernel.gif"
},
{
@ -285,7 +285,7 @@
}
],
"source": "http://www.wired.com/dangerroom/2011/10/drone-virus-nuisance/",
"tier": 7,
"tier": 1,
"image": "data/pix/q_drone.jpg"
},
{
@ -309,7 +309,7 @@
}
],
"source": "http://arstechnica.com/tech-policy/news/2011/10/get-hacked-dont-tell-drone-base-didnt-report-virus.ars",
"tier": 6,
"tier": 3,
"image": "data/pix/q_drone2.jpg"
},
{
@ -333,7 +333,7 @@
}
],
"source": "http://torrentfreak.com/google-starts-censoring-bittorrent-rapidshare-and-more-110126/",
"tier": 3,
"tier": 1,
"image": "data/pix/q_autocomplete.jpg"
},
{
@ -357,7 +357,7 @@
}
],
"source": "http://www.theregister.co.uk/2011/09/07/globalsign_suspends_ssl_cert_biz/",
"tier": 5,
"tier": 8,
"image": "data/pix/q_ca4.jpg"
},
{
@ -381,7 +381,7 @@
}
],
"source": "http://en.wikipedia.org/wiki/South_Sudan",
"tier": 1,
"tier": 3,
"image": "data/pix/q_sudan.png"
},
{
@ -405,7 +405,7 @@
}
],
"source": "http://netzpolitik.org/2011/blackberry-kundigt-an-londoner-plunderer-auszuliefern/",
"tier": 10,
"tier": 1,
"image": "data/pix/q_london.jpg"
},
{
@ -429,7 +429,7 @@
}
],
"source": "http://winfuture.de/news,66539.html",
"tier": 1,
"tier": 7,
"image": "data/pix/q_hackspace.jpg"
}
]

View File

@ -20,7 +20,7 @@
}
],
"source": "http://en.wikipedia.org/wiki/Category:Lists_of_pornographic_film_actors",
"tier": 1767,
"tier": 140,
"image": "data/pix/q_wp_pornstars.png"
},
{
@ -44,7 +44,7 @@
}
],
"source": "http://www.addn.me/freiraeume/handydatenskandal-nimmt-kein-ende/",
"tier": 571,
"tier": 965,
"image": "data/pix/q_handygate.jpg"
},
{
@ -68,7 +68,7 @@
}
],
"source": "http://online.wsj.com/article/SB10001424052970203476804576613284007315072.html",
"tier": 700,
"tier": 1879,
"image": "data/pix/q_dont_be_evil.jpg"
},
{
@ -92,11 +92,11 @@
}
],
"source": "http://arstechnica.com/business/news/2011/10/exclusive-computer-virus-hits-drone-fleet.ars",
"tier": 328,
"tier": 1307,
"image": "data/pix/q_drone-dove.jpg"
},
{
"tier": 194,
"tier": 632,
"text": "To what degree Libre Office is compatible to MS Office documents?",
"image": "data/pix/q_office.jpg",
"answers": [
@ -137,7 +137,7 @@
}
],
"source": "http://www.heise.de/newsticker/meldung/Bericht-Microsoft-verdient-knapp-eine-halbe-Milliarde-an-Android-1351900.html",
"tier": 349,
"tier": 372,
"image": "data/pix/q_android_ms.jpg"
},
{
@ -161,7 +161,7 @@
}
],
"source": "http://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20110928-ipv6mpls",
"tier": 1465,
"tier": 1909,
"image": "data/pix/q_ipv6_ping.jpg"
},
{
@ -185,7 +185,7 @@
}
],
"source": "http://www.internetevolution.com/author.asp?section_id=852&doc_id=233780&",
"tier": 1332,
"tier": 1201,
"image": "data/pix/q_hp_money.jpg"
},
{
@ -209,7 +209,7 @@
}
],
"source": "https://www.infosecisland.com/blogview/16696-FACT-CHECK-SCADA-Systems-Are-Online-Now.html",
"tier": 1776,
"tier": 1383,
"image": "data/pix/q_747.jpg"
}
]

View File

@ -20,7 +20,7 @@
}
],
"source": "https://pentamedia.c3d2.de/submit/2011/09/16/illegaledownloadsschuldantoumldlichemfesti/",
"tier": 350,
"tier": 2899,
"image": "data/pix/q_p2p.jpg"
},
{
@ -44,7 +44,7 @@
}
],
"source": "http://www.theregister.co.uk/2011/09/13/belgium_headed_for_net_neutrality/",
"tier": 261,
"tier": 2297,
"image": "data/pix/q_netneutrality.jpg"
},
{
@ -68,7 +68,7 @@
}
],
"source": "http://www.telegraph.co.uk/technology/news/8753784/The-300m-cable-that-will-save-traders-milliseconds.html",
"tier": 2591,
"tier": 3013,
"image": "data/pix/q_300mdollar.jpg"
},
{
@ -92,7 +92,7 @@
}
],
"source": "http://www.truthwinsout.org/news/2011/03/15155/",
"tier": 228,
"tier": 3074,
"image": "data/pix/van_gogh_ipad.jpg"
},
{
@ -116,7 +116,7 @@
}
],
"source": "https://pentamedia.c3d2.de/submit/2011/09/13/abgeordnetenwatchdesebastianedathy/",
"tier": 2942,
"tier": 3673,
"image": "data/pix/q_edathy.jpg"
},
{
@ -140,7 +140,7 @@
}
],
"source": "http://www.improbable.com/2011/09/07/new-patent-granted-for-building-a-snow-manwoman/",
"tier": 2628,
"tier": 3632,
"image": "data/pix/q_snowman.jpg"
},
{
@ -164,7 +164,7 @@
}
],
"source": "http://www.michaelgeist.ca/content/view/5765/125/",
"tier": 2084,
"tier": 367,
"image": "data/pix/q_copyright.jpg"
},
{
@ -188,7 +188,7 @@
}
],
"source": "https://pentamedia.c3d2.de/submit/2011/08/01/emacsverstotseitjahrengegendiegplheiseo/",
"tier": 951,
"tier": 474,
"image": "data/pix/q_gpl.png"
}
]

View File

@ -20,7 +20,7 @@
}
],
"source": "http://www.bonkersworld.net/wp-content/uploads/2011/06/2011.06.27_organizational_charts.png",
"tier": 47,
"tier": 39,
"image": "data/pix/orgchart-ms.png"
},
{
@ -44,7 +44,7 @@
}
],
"source": "http://www.heise.de/newsticker/meldung/Chaos-Communication-Camp-Vom-Ausbeuten-des-guten-Rufes-2-Update-1323234.html",
"tier": 53,
"tier": 8,
"image": "data/pix/q_fefe.png"
},
{
@ -68,7 +68,7 @@
}
],
"source": "http://cache.gawkerassets.com/assets/images/4/2011/07/sunpage-2.jpg",
"tier": 5,
"tier": 35,
"image": "data/pix/q_death_people.jpg"
},
{
@ -92,7 +92,7 @@
}
],
"source": "http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/",
"tier": 21,
"tier": 14,
"image": "data/pix/q_php.png"
},
{
@ -116,7 +116,7 @@
}
],
"source": "http://www.guardian.co.uk/tv-and-radio/2011/oct/18/tv-review-spains-stolen-babies",
"tier": 32,
"tier": 11,
"image": "data/pix/q_pope.jpg"
},
{
@ -140,7 +140,7 @@
}
],
"source": "http://themoderatevoice.com/114102/americas-rejection-of-evolution-reflected-in-miss-usa-pageant/",
"tier": 18,
"tier": 76,
"image": "data/pix/q_miss_usa.jpg"
},
{
@ -164,7 +164,7 @@
}
],
"source": "http://themoderatevoice.com/114102/americas-rejection-of-evolution-reflected-in-miss-usa-pageant/",
"tier": 27,
"tier": 50,
"image": "data/pix/q_win_exploit.jpg"
},
{
@ -188,7 +188,7 @@
}
],
"source": "http://www.schneier.com/blog/archives/2011/08/alarm_geese.html",
"tier": 76,
"tier": 67,
"image": "data/pix/q_berlin_wall.jpg"
},
{
@ -212,7 +212,7 @@
}
],
"source": "https://pentamedia.c3d2.de/submit/2011/01/30/efffbimayhavecommittedmorethan40kintellig/",
"tier": 62,
"tier": 5,
"image": "data/pix/q_fbi.jpg"
},
{
@ -236,7 +236,7 @@
}
],
"source": "http://toaskornottoask.com/to/shit-that-siri-says/page/2/",
"tier": 72,
"tier": 46,
"image": "data/pix/q_siri.jpg"
},
{
@ -263,7 +263,7 @@
}
],
"source": "http://pwnies.com/winners/",
"tier": 42,
"tier": 64,
"image": "data/pix/q_sony.jpg"
},
{
@ -287,7 +287,7 @@
}
],
"source": "http://pentamedia.c3d2.de/submit/2011/12/22/usinterceptedrussiancosmonautvladimirkomarov/",
"tier": 58,
"tier": 59,
"image": "data/pix/q_soyuz.jpg"
}
]

View File

@ -28,6 +28,11 @@ import os
import sys
import random
import json
from reportlab.lib.pagesizes import A5, LETTER, landscape, portrait
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch, cm
from reportlab.platypus.flowables import PageBreak
from optparse import OptionParser
try:
@ -160,6 +165,18 @@ class Question(yaml.YAMLObject):
data[key] = value
return data
@property
def as_pdf_dict(self):
"""Return full data set. Includes comment field"""
data = self.as_dict
try:
data['comment'] = self.comment
except AttributeError:
data['comment'] = ""
return data
@classmethod
def get_points(cls):
"""docstring for get_points"""
@ -206,6 +223,15 @@ def init_parser():
metavar="FILE",
)
parser.add_option(
"-p",
"--generate-pdf",
dest="pdf",
help=("Generate the speaker PDF"),
action="store_true",
default=False,
)
parser.add_option(
"-v",
"--version",
@ -229,6 +255,61 @@ def write_json_file(questions):
fh = open(file_name, 'w')
fh.writelines(json.dumps([q.as_dict for q in questions], indent=2))
def gen_pdf(questions, game_rounds):
"""generate speaker PDF"""
styles = getSampleStyleSheet()
doc = SimpleDocTemplate("pngs-speaker.pdf")
doc.pagesize = landscape(A5)
style = styles["Normal"]
page_elements = []
for round in game_rounds:
for num, question in enumerate(questions):
q_data = question.as_pdf_dict
page_elements.append(
Paragraph("<em>Game Round</em>: {0}".format(round),
style)
)
page_elements.append(Spacer(0, 0.1*cm))
page_elements.append(
Paragraph(
"<font size=12><em>Question {0}:</em> <bold>{1}</bold>"
"</font>".format(num + 1, q_data['text'].encode('utf-8')),
style)
)
page_elements.append(Spacer(0, 0.2*cm))
page_elements.append(
Paragraph("<em>Comment</em>: {0}".format(q_data.get('comment').encode('utf-8')),
style)
)
page_elements.append(Spacer(0, 0.2*cm))
page_elements.append(
Paragraph("<em>Answers</em>:",
style)
)
page_elements.append(
Paragraph("* " + "<br />* ".join([unicode(t['text']) for t in q_data['answers']]),
style)
)
page_elements.append(
Paragraph("<em>Points</em>: {0}".format(q_data.get('tier')),
style)
)
page_elements.append(PageBreak())
doc.build(page_elements)
return
Story = [Spacer(0, 1*cm)]
p = Paragraph("Blubber1", styles["Normal"])
Story.append(p)
p = Paragraph("Blubber2", styles["Normal"])
Story.append(p)
Story.append(Spacer(10, 5*cm))
p = Paragraph("Blubber3", styles["Normal"])
Story.append(p)
#doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
doc.build(Story)
def main():
"""docstring for main"""
@ -260,6 +341,9 @@ def main():
if options.debug:
print "Written file for game round: {0}".format(r)
if options.pdf:
gen_pdf(questions, game_rounds)
if __name__ == '__main__':
main()