Skip to content

Instantly share code, notes, and snippets.

@miku
Forked from anonymous/README.md
Last active December 18, 2015 13:49
Show Gist options
  • Save miku/5793006 to your computer and use it in GitHub Desktop.
Save miku/5793006 to your computer and use it in GitHub Desktop.

README

Data Sources, Transformations, Sinks. A language to express the flow of data. Textual and graphical. Minimal code. Maximum code reuse. 0-Install.

#!/usr/bin/env python
# coding: utf-8
class CSVComponent(object):
"""
A CSV file or URL.
"""
def __init__(self):
self.url = None
self.in = None
self.out = 'tcp://0.0.0.0:5002'
def __iter__(self):
return self
def next(self):
raise StopIteration
class DatabaseComponent(object):
"""
Is a source of data.
"""
def __init__(self):
self.url = None
self.query = None
self.out = 'tcp://0.0.0.0:5000'
self.in = None
def __iter__(self):
return self
def next(self):
""" ZMQ_PUB """
# TODO: iterator over result set
raise StopIteration
class JsonSerializer(object):
"""
Is a transformer.
"""
def __init__(self):
self.out = 'tcp://0.0.0.0:5001'
self.in = 'tcp://0.0.0.0:4001'
def __iter__(self):
return self
def next(self):
raise StopIteration
class FileWriter(object):
"""
Writes to a file - a sink.
"""
def __init__(self):
self.in = 'tcp://0.0.0.0:4001'
self.out = None
def __iter__(self):
return self
def next(self):
raise StopIteration
if __name__ == '__main__':
db = DatabaseComponent()
db.url = 'sqlite:////tmp/test.db'
db.query = 'select * from user'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment