minor cleanups in emitters

This commit is contained in:
James Turk 2010-02-21 14:21:19 -05:00
parent a6574ecba7
commit 6ffce4cf6e

View File

@ -11,14 +11,10 @@ class Emitter(Filter):
All derived emitters must provide an emit_record(self, record) that All derived emitters must provide an emit_record(self, record) that
takes a single record (python dictionary). takes a single record (python dictionary).
Emitters can optionally define a close() method that is called after Emitters can optionally define a done() method that is called after
all records are processed (allowing database flushes, or printing of all records are processed (allowing database flushes, or printing of
aggregate data). aggregate data).
""" """
def __init__(self):
super(Emitter, self).__init__()
def process_record(self, record): def process_record(self, record):
self.emit_record(record) self.emit_record(record)
return record return record
@ -64,7 +60,7 @@ class CSVEmitter(Emitter):
records to a csvfile with the columns in the order specified. records to a csvfile with the columns in the order specified.
""" """
def __init__(self, csvfile, fieldnames=None): def __init__(self, csvfile, fieldnames):
super(CSVEmitter, self).__init__() super(CSVEmitter, self).__init__()
import csv import csv
self._dictwriter = csv.DictWriter(csvfile, fieldnames) self._dictwriter = csv.DictWriter(csvfile, fieldnames)