From ee695be444a94a34c8aec145a36d340cc706face Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Thu, 9 Dec 2010 22:33:46 -0800 Subject: [PATCH] supybotconfig/writers - fix kwargs parsing for writers Ignore-this: 33766800fdcf08e51fd4e331a327b0ee - Fix .ext|arg1=val1|arg2=val2 parsing for arguments which have a colon. - Add documentation to how to use this system. darcs-hash:20101210063346-82ea9-50c452663ce543ed46fc7c90137e60a9cb7ed20a.gz --- MeetBot/supybotconfig.py | 2 +- ircmeeting/writers.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/MeetBot/supybotconfig.py b/MeetBot/supybotconfig.py index b82039e..d4921a9 100644 --- a/MeetBot/supybotconfig.py +++ b/MeetBot/supybotconfig.py @@ -51,7 +51,7 @@ class WriterMap(registry.String): writer_map = { } for writer in s: #from fitz import interact ; interact.interact() - writer, ext = writer.split(':') + writer, ext = writer.split(':', 1) if not hasattr(writers, writer): raise ValueError("Writer name not found: %s"%writer) #if len(ext) < 2 or ext[0] != '.': diff --git a/ircmeeting/writers.py b/ircmeeting/writers.py index 7787235..b5207d9 100644 --- a/ircmeeting/writers.py +++ b/ircmeeting/writers.py @@ -82,7 +82,7 @@ class _BaseWriter(object): def __init__(self, M, **kwargs): self.M = M - def format(self, extension=None): + def format(self, extension=None, **kwargs): """Override this method to implement the formatting. For file output writers, the method should return a unicode @@ -91,6 +91,13 @@ class _BaseWriter(object): 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, + + **kwargs is a dictionary of keyword arguments which are found + via parsing the extension to the writer. If an extension is + this: + .txt|arg1=val1|arg2=val2 + then kwargs will be passed as {'arg1':'val1', 'arg2':'val2'}. + This can be used for extra configuration for writers. """ raise NotImplementedError