Data Sources, Transformations, Sinks. A language to express the flow of data. Textual and graphical. Minimal code. Maximum code reuse. 0-Install.
-
-
Save miku/5793006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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