30 lines
474 B
Python
30 lines
474 B
Python
# standard imports
|
|
import os
|
|
import sys
|
|
|
|
|
|
class OutputWriter:
|
|
|
|
def write(self, k, v):
|
|
raise NotImplementedError()
|
|
|
|
|
|
class StdoutWriter:
|
|
|
|
def write(self, k, v):
|
|
sys.stdout.write('{}\t{}\n'.format(k, v))
|
|
|
|
|
|
class KVWriter(OutputWriter):
|
|
|
|
def __init__(self, path):
|
|
os.stat(path)
|
|
self.path = path
|
|
|
|
|
|
def write(self, k, v):
|
|
fp = os.path.join(self.path, str(k))
|
|
f = open(fp, 'wb')
|
|
f.write(v)
|
|
f.close()
|