Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 2
Fetching contributors…

Cannot retrieve contributors at this time

executable file 49 lines (37 sloc) 1.321 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/usr/bin/env python

import os
import sys
import shutil

from glob import glob
from debian_bundle import deb822
from xml.dom.minidom import Document

def main(dir):
    num = 0

    doc = Document()
    events = doc.createElement('data')
    doc.appendChild(events)

    for filename in glob(os.path.join(dir, '*')):
        print >>sys.stderr, "Reading events from %s" % filename,
        for para in deb822.Deb822.iter_paragraphs(file(filename)):
            events.appendChild(create_event(doc, para))
            sys.stderr.write('.')
            num += 1
        print >>sys.stderr

    print >>sys.stderr, "Writing %s events" % num

    print '<!-- Generated from %s/* - do not edit -->' % dir
    print events.toprettyxml(indent=' ')

def create_event(doc, para):
    entry = doc.createElement('entry')
    entry.setAttribute('title', para['Title'])

    if 'Start-Date' in para:
        entry.setAttribute('isDuration', 'true')
        entry.setAttribute('start', para['Start-Date'])
        entry.setAttribute('end', para['End-Date'])
    else:
        entry.setAttribute('start', para['Date'])

    if 'Source' in para:
        text = doc.createTextNode('<a href="%s">Source</a>' % para['Source'])
        entry.appendChild(text)

    return entry

if __name__ == '__main__':
    sys.exit(main(sys.argv[1]))
Something went wrong with that request. Please try again.