# standard imports import os import sys import logging logg = logging.getLogger(__name__) class OutputWriter: def __init__(self, *args, **kwargs): pass def write(self, k, v): raise NotImplementedError() class StdoutWriter(OutputWriter): def write(self, k, v): sys.stdout.write('{}\t{}\n'.format(k, v)) class KVWriter(OutputWriter): def __init__(self, path=None, *args, **kwargs): os.stat(path) self.path = path def write(self, k, v): fp = os.path.join(self.path, str(k)) logg.debug('path write {} {}'.format(fp, str(v))) f = open(fp, 'wb') f.write(v) f.close()