From c2cfd4abd2c930b0166685f032cdb9ad8166a354 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Mon, 14 Sep 2009 15:53:37 +0000 Subject: Add MediaWiki writer prototype - This is just a copy of the Text writer for now, no changes have been made for the MediaWiki syntax yet. - This will allow a nice diff of how Text has to be changed to become MediaWiki once I make the next commit. darcs-hash:20090914155337-82ea9-1e1fe08d58d85f8da6189a75b105f20cf3d41f8b.gz --- (limited to 'writers.py') diff --git a/writers.py b/writers.py index 4f0ad86..0eaa397 100644 --- a/writers.py +++ b/writers.py @@ -859,3 +859,126 @@ class Text(_BaseWriter): return body +class MediaWiki(_BaseWriter): + """Outputs MediaWiki formats. + """ + def meetingItems(self): + M = self.M + + # Agenda items + MeetingItems = [ ] + MeetingItems.append(self.heading('Meeting summary')) + haveTopic = None + for m in M.minutes: + item = "* "+m.text(M) + if m.itemtype == "TOPIC": + if haveTopic: + MeetingItems.append("") + item = wrapList(item, 0) + haveTopic = True + else: + if haveTopic: item = wrapList(item, 2) + else: item = wrapList(item, 0) + MeetingItems.append(item) + MeetingItems = '\n'.join(MeetingItems) + return MeetingItems + + def actionItems(self): + M = self.M + # Action Items + ActionItems = [ ] + ActionItems.append(self.heading('Action items')) + for m in M.minutes: + # The hack below is needed because of pickling problems + if m.itemtype != "ACTION": continue + #already escaped + ActionItems.append(wrapList("* %s"%text(m.line), indent=0)) + ActionItems = "\n".join(ActionItems) + + def actionItemsPerson(self): + M = self.M + # Action Items, by person (This could be made lots more efficient) + ActionItemsPerson = [ ] + ActionItemsPerson.append(self.heading('Action items, by person')) + numberAssigned = 0 + for nick in sorted(M.attendees.keys(), key=lambda x: x.lower()): + headerPrinted = False + for m in M.minutes: + # The hack below is needed because of pickling problems + if m.itemtype != "ACTION": continue + if m.line.find(nick) == -1: continue + if not headerPrinted: + ActionItemsPerson.append("* %s"%text(nick)) + headerPrinted = True + ActionItemsPerson.append(wrapList("* %s"%text(m.line), 2)) + numberAssigned += 1 + m.assigned = True + # unassigned items: + Unassigned = [ ] + Unassigned.append("* **UNASSIGNED**") + numberUnassigned = 0 + for m in M.minutes: + if m.itemtype != "ACTION": continue + if getattr(m, 'assigned', False): continue + Unassigned.append(wrapList("* %s"%text(m.line), 2)) + numberUnassigned += 1 + if numberUnassigned == 0: + Unassigned.append(" * (none)") + if numberUnassigned > 1: + ActionItemsPerson.extend(Unassigned) + ActionItemsPerson = "\n".join(ActionItemsPerson) + + if numberAssigned == 0: + return None + else: + return ActionItemsPerson + + def peoplePresent(self): + M = self.M + # People Attending + PeoplePresent = [ ] + PeoplePresent.append(self.heading('People present (lines said)')) + # sort by number of lines spoken + for nick, count in self.iterNickCounts(): + PeoplePresent.append('* %s (%s)'%(text(nick), count)) + PeoplePresent = "\n".join(PeoplePresent) + return PeoplePresent + + def heading(self, name): + return '%s\n%s\n'%(name, '-'*len(name)) + + + def format(self, extension=None): + """Return a ReStructured Text minutes summary.""" + M = self.M + + # Actual formatting and replacement + repl = self.replacements() + repl.update({'titleBlock':('='*len(repl['pageTitle'])), + }) + + + body = [ ] + body.append(textwrap.dedent("""\ + %(titleBlock)s + %(pageTitle)s + %(titleBlock)s + + + sWRAPsMeeting started by %(owner)s at %(starttime)s + %(timeZone)s. The full logs are available at + %(fullLogsFullURL)s .eWRAPe"""%repl)) + body.append(self.meetingItems()) + body.append(textwrap.dedent("""\ + Meeting ended at %(endtime)s %(timeZone)s."""%repl)) + body.append(self.actionItems()) + body.append(self.actionItemsPerson()) + body.append(self.peoplePresent()) + body.append(textwrap.dedent("""\ + Generated by `MeetBot`_%(MeetBotVersion)s"""%repl)) + body = [ b for b in body if b is not None ] + body = "\n\n\n\n".join(body) + body = replaceWRAP(body) + + return body + -- cgit v0.9.1