cic-cli/cic/output.py

33 lines
565 B
Python
Raw Normal View History

# standard imports
import os
import sys
class OutputWriter:
2021-10-12 08:39:20 +02:00
def __init__(self, *args, **kwargs):
pass
def write(self, k, v):
raise NotImplementedError()
2021-10-12 08:39:20 +02:00
class StdoutWriter(OutputWriter):
def write(self, k, v):
sys.stdout.write('{}\t{}\n'.format(k, v))
class KVWriter(OutputWriter):
2021-10-12 08:39:20 +02:00
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))
f = open(fp, 'wb')
f.write(v)
f.close()