class DisplayHTMLBlock(object): def __init__(self, title): self.title = title def build(self, f): pass class DisplayHTMLBlockTable(DisplayHTMLBlock): def __init__(self, title, cols): super(DisplayHTMLBlockTable, self).__init__(title) self.cols = cols self.rows = [] def appendRow(self, row): self.rows.append(row) def build(self, f): f.write('') f.write('') for title in self.cols: f.write('' % (title)) f.write('') for row in self.rows: f.write('') for v in row: f.write('' % (v)) f.write('') f.write('
%s
%s
') class DisplayHTMLPage(object): def __init__(self, title, filename): self.title = title self.filename = filename self.blocks = [] def getFilename(self): return self.filename; def appendBlock(self, block): self.blocks.append(block) def build(self, root): f = open(root + self.filename, 'w') f.write('%s' % (self.title)) for block in self.blocks: block.build(f) f.write('') f.close() class DisplayHTMLBuild(object): def __init__(self): self.pages = [] def getPage(self, filename): for page in self.pages: if page.getFilename() == filename: return page return None def addPage(self, page): self.pages.append(page) def build(self, root): for page in self.pages: page.build(root)