def print_venue(entry): result = '' if entry.end > time.localtime(): result += 'I shall attend ' else: result += 'I attended ' result += 'the ' if 'url' in entry: if 'abbreviation' in entry: result += entry.text + ' (<a href="' + entry.url + '">' + entry.abbreviation + '</a>)' else: result += '<a href="' + entry.url + '">' + entry.text + '</a>' else: result += entry.text if 'abbreviation' in entry: result += ' (' + entry.abbreviation + ')' result += ' in ' + placelink(entry.venue) result += ' (' + timeperiod(entry.begin, entry.end) + ')' if 'talkid' in entry: # read data XML file xml = XML2Dict() data = xml.fromstring(open('../xml/presentations.xml', 'r').read()) # transform date types for entry2 in data.presentations.conferences.talk: entry2.date = time.strptime(entry2.date, '%d %b %Y') for entry2 in data.presentations.workshops.talk: entry2.date = time.strptime(entry2.date, '%d %b %Y') # look for talk with given id for entry2 in data.presentations.conferences.talk: if entry2.id == entry.talkid: t = entry2.title d = entry2.date for entry2 in data.presentations.workshops.talk: if entry2.id == entry.talkid: t = entry2.title d = entry2.date result += ' and ' if entry.end > time.localtime(): result += 'give ' else: result += 'gave ' result += 'a talk on “<a href="presentations.html#' + entry.talkid + '">' + t + '</a>.”' # only print presentation date if venue is longer than one day if entry.begin != entry.end: result += ' (' + timeperiod(d, d) + ')' result += '.' return result
def print_lecture(entry): result = '' if entry.end > time.localtime(): result += 'I shall give a talk ' else: result += 'I gave a talk ' if 'talkid' in entry: result += 'on “<a href="presentations.html#' + entry.talkid + '">' + entry.title + '</a>” at the ' else: result += 'on “' + entry.title + '” at the ' if 'url' in entry: result += '<a href="' + entry.url + '">' + entry.text + '</a>' else: result += entry.text result += ' in ' + placelink(entry.venue) result += ' (' + timeperiod(entry.begin, entry.end) + ')' return result
def presentations(): # add header template print("Generating presentations.html...") output = open('../html/presentations.html', 'r').read() # read data XML file xml = XML2Dict() data = xml.fromstring(open('../xml/presentations.xml', 'r').read()) ######################### # part 1: Invited Talks # ######################### # transform date types for entry in data.presentations.invited.talk: entry.date = time.strptime(entry.date, '%d %b %Y') # sort by begin date data.presentations.invited.talk = sorted(data.presentations.invited.talk, key=lambda k: k.date, reverse=True) output += '<h2 class="first">Invited Presentations</h2>' output += '<ul class="talks">\n' for entry in data.presentations.invited.talk: output += '<li id="' + entry.id + '">' if 'slideshare' in entry: output += '<a href="' + entry.slideshare + '" title="slides of the talk at Slideshare"></a>' if 'vimeo' in entry: output += '<a href="' + entry.vimeo + '" title="video of the talk at Vimeo"></a>' output += '<strong>' + entry.title + '</strong><br/>' output += entry.detail + '<br/>' if entry.date > time.localtime(): output += 'to be held on ' output += timeperiod(entry.date, entry.date) + ' in ' + placelink(entry.venue) output += '</li>\n' # output for Slideshare.net stdoutput = '\nInvited presentation given by Niels Lohmann on ' + timeperiod(entry.date, entry.date) stdoutput += ' in ' + entry.venue + ' as ' + entry.detail if stdoutput[-1] != '.': stdoutput += '.\n' sys.stderr.write(stdoutput) output += '</ul>\n' ############################ # part 2: Conference Talks # ############################ # transform date types for entry in data.presentations.conferences.talk: entry.date = time.strptime(entry.date, '%d %b %Y') # sort by begin date data.presentations.conferences.talk = sorted(data.presentations.conferences.talk, key=lambda k: k.date, reverse=True) output += '<h2>Conference Presentations</h2>' output += '<ul class="talks">\n' for entry in data.presentations.conferences.talk: output += '<li id="' + entry.id + '">' if 'slideshare' in entry: output += '<a href="' + entry.slideshare + '" title="slides of the talk at Slideshare"></a>' if 'vimeo' in entry: output += '<a href="' + entry.vimeo + '" title="video of the talk at Vimeo"></a>' output += '<strong>' + entry.title + '</strong><br/>' if 'abbreviation' in entry: output += '<em>' + entry.conference + ' (<a href="' + entry.url + '">' + entry.abbreviation.replace(" ", " ") + '</a>)</em><br/>' else: output += '<em><a href="' + entry.url + '">' + entry.conference + ' </a></em><br/>' if entry.date > time.localtime(): output += 'to be held on ' output += timeperiod(entry.date, entry.date) + ' in ' + placelink(entry.venue) output += '</li>\n' # output for Slideshare.net stdoutput = '\nConference presentation given by Niels Lohmann on ' + timeperiod(entry.date, entry.date) stdoutput += ' in ' + entry.venue + ' at the ' + entry.conference if 'abbreviation' in entry: stdoutput += ' (' + entry.abbreviation + ')' stdoutput += '.\n' sys.stderr.write(stdoutput) output += '</ul>\n' ########################## # part 3: Workshop Talks # ########################## # transform date types for entry in data.presentations.workshops.talk: entry.date = time.strptime(entry.date, '%d %b %Y') # sort by begin date data.presentations.workshops.talk = sorted(data.presentations.workshops.talk, key=lambda k: k.date, reverse=True) output += '<h2>Workshop Presentations</h2>' output += '<ul class="talks">\n' for entry in data.presentations.workshops.talk: output += '<li id="' + entry.id + '">' if 'slideshare' in entry: output += '<a href="' + entry.slideshare + '" title="slides of the talk at Slideshare"></a>' if 'vimeo' in entry: output += '<a href="' + entry.vimeo + '" title="video of the talk at Vimeo"></a>' output += '<strong>' + entry.title + '</strong><br/>' if 'abbreviation' in entry: if 'url' in entry: output += '<em>' + entry.conference + ' (<a href="' + entry.url + '">' + entry.abbreviation.replace(" ", " ") + '</a>)' else: output += '<em>' + entry.conference + ' (' + entry.abbreviation.replace(" ", " ") + ')' else: if 'url' in entry: output += '<em><a href="' + entry.url + '">' + entry.conference + '</a>' else: output += '<em>' + entry.conference if 'colocation' in entry: if 'courl' in entry: output += '; part of <a href="' + entry.courl + '">' + entry.colocation.replace(" ", " ") + '</a>' else: output += '; part of ' + entry.colocation.replace(" ", " ") output += '</em><br/>' if entry.date > time.localtime(): output += 'to be held on ' output += timeperiod(entry.date, entry.date) + ' in ' + placelink(entry.venue) output += '</li>\n' # output for Slideshare.net stdoutput = '\nWorkshop presentation given by Niels Lohmann on ' + timeperiod(entry.date, entry.date) stdoutput += ' in ' + entry.venue + ' at the ' + entry.conference if 'abbreviation' in entry: stdoutput += ' (' + entry.abbreviation + ')' if 'colocation' in entry: stdoutput += '; part of ' + entry.colocation stdoutput += '.\n' sys.stderr.write(stdoutput) output += '</ul>\n' ########################## # part 4: Demonstrations # ########################## # transform date types for entry in data.presentations.demonstrations.talk: entry.date = time.strptime(entry.date, '%d %b %Y') # sort by begin date data.presentations.demonstrations.talk = sorted(data.presentations.demonstrations.talk, key=lambda k: k.date, reverse=True) output += '<h2>Tool Demonstrations</h2>' output += '<ul class="talks">\n' for entry in data.presentations.demonstrations.talk: output += '<li id="' + entry.id + '">' if 'slideshare' in entry: output += '<a href="' + entry.slideshare + '" title="slides of the talk at Slideshare"></a>' if 'vimeo' in entry: output += '<a href="' + entry.vimeo + '" title="video of the talk at Vimeo"></a>' output += '<strong>' + entry.title + '</strong><br/>' if 'abbreviation' in entry: if 'url' in entry: output += '<em>' + entry.conference + ' (<a href="' + entry.url + '">' + entry.abbreviation.replace(" ", " ") + '</a>)' else: output += '<em>' + entry.conference + ' (' + entry.abbreviation.replace(" ", " ") + ')' else: if 'url' in entry: output += '<em><a href="' + entry.url + '">' + entry.conference + '</a>' else: output += '<em>' + entry.conference if 'colocation' in entry: if 'courl' in entry: output += '; part of <a href="' + entry.courl + '">' + entry.colocation.replace(" ", " ") + '</a>' else: output += '; part of ' + entry.colocation.replace(" ", " ") output += '</em><br/>' output += timeperiod(entry.date, entry.date) + ' in ' + placelink(entry.venue) output += '</li>\n' # output for Slideshare.net stdoutput = '\nTool demonstration given by Niels Lohmann on ' + timeperiod(entry.date, entry.date) stdoutput += ' in ' + entry.venue + ' at the ' + entry.conference if 'abbreviation' in entry: stdoutput += ' (' + entry.abbreviation + ')' if 'colocation' in entry: stdoutput += '; part of ' + entry.colocation stdoutput += '.\n' sys.stderr.write(stdoutput) output += '</ul>\n' ######################### # part 5: Miscellaneous # ######################### # transform date types for entry in data.presentations.miscellaneous.talk: entry.date = time.strptime(entry.date, '%d %b %Y') # sort by begin date data.presentations.miscellaneous.talk = sorted(data.presentations.miscellaneous.talk, key=lambda k: k.date, reverse=True) output += '<h2>Miscellaneous</h2>' output += '<ul class="talks">\n' for entry in data.presentations.miscellaneous.talk: output += '<li id="' + entry.id + '">' output += '<a href="' + entry.slideshare + '" title="slides of the talk at Slideshare"></a>' if 'vimeo' in entry: output += '<a href="' + entry.vimeo + '" title="video of the talk at Vimeo"></a>' output += '<strong>' + entry.title + '</strong><br/>' output += entry.detail + '<br/>' output += timeperiod(entry.date, entry.date) + ' in ' + placelink(entry.venue) output += '</li>\n' # output for Slideshare.net stdoutput = '\nPresentation given by Niels Lohmann on ' + timeperiod(entry.date, entry.date) stdoutput += ' in ' + entry.venue + '; ' + entry.detail stdoutput += '.\n' sys.stderr.write(stdoutput) output += '</ul>\n' # footer output += '</div></div>' output += footer() output += '</body></html>' print("Writing presentations.html...") f = open('../../presentations.html', 'w') f.write(output.replace(" & ", " & ").replace(" - ", " — ")) f.close()