From 9db165ab72d1af47996a9f9d2d4e0163517d7ed8 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Mon, 06 Jul 2009 23:31:13 +0000 Subject: Some updates to names and semantics of writers - RST -> ReST - add the argument "extension darcs-hash:20090706233113-82ea9-f3b6b93a72b939881be3bdb7be14f65f2b5a2ed3.gz --- diff --git a/meeting.py b/meeting.py index 64c8061..a3e6338 100644 --- a/meeting.py +++ b/meeting.py @@ -139,8 +139,8 @@ class Config(object): writer_map = { '.log.html':writers.HTMLlog, '.html': writers.HTML, - '.txt': writers.RST, - '.rst.html':writers.HTMLfromRST, + '.txt': writers.ReST, + '.rst.html':writers.HTMLfromReST, } def save(self): """Write all output files.""" diff --git a/writers.py b/writers.py index e97524f..e6d7a8e 100644 --- a/writers.py +++ b/writers.py @@ -39,6 +39,18 @@ class _BaseWriter(object): def __init__(self, M): self.M = M + def format(self, extension=None): + """Override this method to implement the formatting. + + For file output writers, the method should return a unicode + object containing the contents of the file to write. + + The argument 'extension' is the key from `writer_map`. For + file writers, this can (and should) be ignored. For non-file + outputs, this can be used to This can be used to pass data, + """ + raise NotImplementedError + @property def pagetitle(self): if self.M._meetingTopic: @@ -77,14 +89,14 @@ class _BaseWriter(object): class TextLog(_BaseWriter): - def format(self): + def format(self, extension=None): M = self.M """Write raw text logs.""" return "\n".join(M.lines) class HTMLlog(_BaseWriter): - def format(self): + def format(self, extension=None): """Write pretty HTML logs.""" M = self.M # pygments lexing setup: @@ -153,7 +165,7 @@ class HTML(_BaseWriter): ''') - def format(self): + def format(self, extension=None): """Write the minutes summary.""" M = self.M @@ -213,7 +225,7 @@ class HTML(_BaseWriter): return body -class RST(_BaseWriter): +class ReST(_BaseWriter): body = textwrap.dedent("""\ %(titleBlock)s @@ -263,7 +275,7 @@ class RST(_BaseWriter): .. _`MeetBot`: %(MeetBotInfoURL)s """) - def format(self): + def format(self, extension=None): """Return a ReStructured Text minutes summary.""" M = self.M @@ -339,12 +351,12 @@ class RST(_BaseWriter): body = body%repl return body -class HTMLfromRST(_BaseWriter): +class HTMLfromReST(_BaseWriter): - def format(self): + def format(self, extension=None): M = self.M import docutils.core - rst = RST(M).format() + rst = ReST(M).format(extension) rstToHTML = docutils.core.publish_string(rst, writer_name='html', settings_overrides={'file_insertion_enabled': 0, 'raw_enabled': 0, -- cgit v0.9.1