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
This commit is contained in:
Richard Darst 2010-12-09 22:33:46 -08:00
parent 601bd9a394
commit ee695be444
2 changed files with 9 additions and 2 deletions

View File

@ -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] != '.':

View File

@ -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