Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meeting.py12
-rw-r--r--supybotconfig.py4
-rw-r--r--writers.py33
3 files changed, 26 insertions, 23 deletions
diff --git a/meeting.py b/meeting.py
index 56fdfef..c151885 100644
--- a/meeting.py
+++ b/meeting.py
@@ -135,18 +135,18 @@ class Config(object):
return os.path.basename(self.filename())
writer_map = {
- '.log.html':writers.HTMLlog(),
- '.html': writers.HTML(),
- '.txt': writers.RST(),
- #'.rst.html':writers.HTMLfromRST(),
+ '.log.html':writers.HTMLlog,
+ '.html': writers.HTML,
+ '.txt': writers.RST,
+ '.rst.html':writers.HTMLfromRST,
}
def save(self):
"""Write all output files."""
if self.M._writeRawLog:
- self.writer_map['.log.txt'] = writers.TextLog()
+ self.writer_map['.log.txt'] = writers.TextLog
for extension, writer in self.writer_map.iteritems():
rawname = self.filename()
- text = writer.format(self.M)
+ text = writer(self.M).format()
f = open(rawname+extension, 'w')
if self.M._restrictlogs: self.restrictPermissions(f)
f.write(self.enc(text))
diff --git a/supybotconfig.py b/supybotconfig.py
index 8282f0b..deb6585 100644
--- a/supybotconfig.py
+++ b/supybotconfig.py
@@ -36,12 +36,12 @@ class WriterMap(registry.String):
for e, w in writer_map.iteritems():
if not hasattr(w, "format"):
raise ValueError("Writer %s must have method .format()"%
- w.__class__.__name__)
+ w.__name__)
self.value = writer_map
def __str__(self):
writers_string = [ ]
for ext, w in self.value.iteritems():
- name = w.__class__.__name__
+ name = w.__name__
writers_string.append("%s:%s"%(name, ext))
return " ".join(writers_string)
diff --git a/writers.py b/writers.py
index 57cf7b0..8ea62b6 100644
--- a/writers.py
+++ b/writers.py
@@ -19,17 +19,20 @@ def rst(text):
return text
class _BaseWriter(object):
- pass
+ def __init__(self, M):
+ self.M = M
-class TextLog(object):
- def format(self, M):
+class TextLog(_BaseWriter):
+ def format(self):
+ M = self.M
"""Write raw text logs."""
return "\n".join(M.lines)
-class HTMLlog(object):
- def format(self, M):
+class HTMLlog(_BaseWriter):
+ def format(self):
"""Write pretty HTML logs."""
+ M = self.M
# pygments lexing setup:
# (pygments HTML-formatter handles HTML-escaping)
import pygments
@@ -57,9 +60,10 @@ class HTMLlog(object):
return out
-class HTML(object):
- def format(self, M):
+class HTML(_BaseWriter):
+ def format(self):
"""Write the minutes summary."""
+ M = self.M
data = [ ]
if M._meetingTopic:
pageTitle = "%s: %s"%(M.channel, M._meetingTopic)
@@ -145,12 +149,10 @@ class HTML(object):
return "\n".join(data)
-class RST(object):
- def __init__(self):
- pass
-
- def format(self, M):
+class RST(_BaseWriter):
+ def format(self):
"""Return a ReStructured Text minutes summary."""
+ M = self.M
dedent = textwrap.dedent
wrap = textwrap.wrap
fill = textwrap.fill
@@ -307,11 +309,12 @@ class RST(object):
#osys.exit()
return body
-class HTMLfromRST(object):
+class HTMLfromRST(_BaseWriter):
- def format(self, M):
+ def format(self):
+ M = self.M
import docutils.core
- rst = RST().format(M)
+ rst = RST(M).format()
rstToHTML = docutils.core.publish_string(rst, writer_name='html',
settings_overrides={'file_insertion_enabled': 0,
'raw_enabled': 0})