def tools(): # add header template print("Generating tools.html...") output = open('../html/tools.html', 'r').read() # read data XML file xml = XML2Dict() data = xml.fromstring(open('../xml/tools.xml', 'r').read()) # fetch papers paperdata = generate_publications.init() first = True for entry in data.tooling.tools.tool: release = time.strptime(entry.release, '%d %b %Y') if first: output += '<h2 class="first">' + entry.name + '</h2>' first = False else: output += '<h2>' + entry.name + '</h2>' output += '<ul class="talks">\n' output += '<li>' + entry.description.replace(entry.name, '<strong>' + entry.name + '</strong>') + '</li>\n' if 'paper' in entry: output += generate_publications.formatentry(generate_publications.entrybyname(entry.paper, paperdata)) + '\n' if 'codevelopers' in entry: if entry.codevelopers.find('and') != -1: output += '<li>co-developers: ' + entry.codevelopers + '</li>\n' else: output += '<li>co-developer: ' + entry.codevelopers + '</li>\n' output += '<li>development status: ' + entry.status + '</li>\n' output += '<li>latest release: ' + timeperiod(release, release) + '</li>\n' output += '</ul>\n' # footer output += '</div></div>' output += footer() output += '</body></html>' print("Writing tools.html...") f = open('../../tools.html', 'w') f.write(output.replace(" & ", " & ").replace(" - ", " — ")) f.close()
def news(): # add header template print("Generating index.html...") output = open('../html/index.html', 'r').read() # read data XML file xml = XML2Dict() data = xml.fromstring(open('../xml/news.xml', 'r').read()) # fetch papers paperdata = generate_publications.init() past = [] past_images = [] past_sticky = 0 max_entries = 6 present = [] future = [] # add academic services everything = data.newsentries.entries.news + read_academic() for entry in data.newsentries.entries.news: entry.begin = time.strptime(entry.begin, '%d %b %Y') if 'end' in entry: entry.end = time.strptime(entry.end, '%d %b %Y') else: entry.end = entry.begin # sort by begin date everything = sorted(everything, key=lambda k: k.begin, reverse=True) # get sticky entries, images and sort into past and future for entry in everything: if entry.end > time.localtime(): future.append(entry) continue if entry.begin < time.localtime(): past.append(entry) if 'image' in entry: past_images.append([entry.image, entry.text]) if 'sticky' in entry: past_sticky += 1 continue present.append(entry) future.reverse() ######################################################################## if len(future) > 0: output += '<h2 style="margin-top: 1em;">Soon…</h2>\n' output += '<ul class="news">\n' count = 0 for entry in future: count += 1 if count > max_entries and 'sticky' not in entry: continue output += '<li>' if entry.type == 'free': output += print_free(entry) if entry.type == 'visit': output += print_visit(entry) if entry.type == 'lecture': output += print_lecture(entry) if entry.type == 'venue': output += print_venue(entry) output += '</li>\n' output += '</ul>\n' ######################################################################## if len(past) > 0: output += '<h2 style="margin-top: 1em;">Recently…</h2>\n' for img in past_images: output += '<img src="resources/img/' + img[0] + '" alt="' + img[1] + '" style="padding-left:10px; padding-bottom:10px; float: right;" />' output += '<ul class="news">\n' count = 0 for entry in past: count += 1 if count > (max_entries-past_sticky) and 'sticky' not in entry: continue output += '<li>' if entry.type == 'pc': output += print_pc(entry) if entry.type == 'free': output += print_free(entry) if entry.type == 'visit': output += print_visit(entry) if entry.type == 'lecture': output += print_lecture(entry) if entry.type == 'venue': output += print_venue(entry) if entry.type == 'paper_accepted': output += print_paper_accepted(entry, paperdata) output += '</li>\n' output += '</ul>\n' ######################################################################## # footer output += '</div></div>' output += footer() output += '</body></html>' print("Writing index.html...") f = open('../../index.html', 'w') f.write(output.replace(" & ", " & ").replace(" - ", " — ")) f.close()