Delete old files
This commit is contained in:
@ -5,6 +5,11 @@ from bonobo.examples.datasets.services import get_services
|
|||||||
|
|
||||||
|
|
||||||
def get_graph(graph=None, *, _limit=(), _print=()):
|
def get_graph(graph=None, *, _limit=(), _print=()):
|
||||||
|
"""
|
||||||
|
Extracts a list of cafes with on euro in Paris, renames the name, address and zipcode fields,
|
||||||
|
reorders the fields and formats to json and csv files.
|
||||||
|
|
||||||
|
"""
|
||||||
graph = graph or bonobo.Graph()
|
graph = graph or bonobo.Graph()
|
||||||
|
|
||||||
producer = graph.add_chain(
|
producer = graph.add_chain(
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Extracts a list of fablabs in the world, restrict to the ones in france, then format it both for a nice console output
|
Extracts a list of fablabs in the world, restricted to the ones in france, then format its both for a nice console output
|
||||||
and a flat txt file.
|
and a flat txt file.
|
||||||
|
|
||||||
.. graphviz::
|
.. graphviz::
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
from bonobo import open_examples_fs
|
|
||||||
|
|
||||||
|
|
||||||
def get_services():
|
|
||||||
return {'fs': open_examples_fs('datasets')}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import bonobo
|
|
||||||
|
|
||||||
|
|
||||||
def extract():
|
|
||||||
yield 'foo'
|
|
||||||
yield 'bar'
|
|
||||||
yield 'baz'
|
|
||||||
|
|
||||||
|
|
||||||
def transform(x):
|
|
||||||
return x.upper()
|
|
||||||
|
|
||||||
|
|
||||||
def load(x):
|
|
||||||
print(x)
|
|
||||||
|
|
||||||
|
|
||||||
graph = bonobo.Graph(extract, transform, load)
|
|
||||||
|
|
||||||
graph.__doc__ = 'hello'
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph)
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import bonobo
|
|
||||||
|
|
||||||
graph = bonobo.Graph(
|
|
||||||
[
|
|
||||||
'foo',
|
|
||||||
'bar',
|
|
||||||
'baz',
|
|
||||||
],
|
|
||||||
str.upper,
|
|
||||||
print,
|
|
||||||
)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph)
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import bonobo
|
|
||||||
|
|
||||||
graph = bonobo.Graph(
|
|
||||||
bonobo.FileReader('coffeeshops.txt'),
|
|
||||||
print,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_services():
|
|
||||||
return {'fs': bonobo.open_examples_fs('datasets')}
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph, services=get_services())
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import bonobo
|
|
||||||
|
|
||||||
|
|
||||||
def split_one(line):
|
|
||||||
return dict(zip(("name", "address"), line.split(', ', 1)))
|
|
||||||
|
|
||||||
|
|
||||||
graph = bonobo.Graph(
|
|
||||||
bonobo.FileReader('coffeeshops.txt'),
|
|
||||||
split_one,
|
|
||||||
bonobo.JsonWriter('coffeeshops.json', fs='fs.output'),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_services():
|
|
||||||
return {
|
|
||||||
'fs': bonobo.open_examples_fs('datasets'),
|
|
||||||
'fs.output': bonobo.open_fs(),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph, services=get_services())
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
import json
|
|
||||||
|
|
||||||
import bonobo
|
|
||||||
|
|
||||||
|
|
||||||
def split_one_to_map(line):
|
|
||||||
k, v = line.split(', ', 1)
|
|
||||||
return {k: v}
|
|
||||||
|
|
||||||
|
|
||||||
class MyJsonWriter(bonobo.JsonWriter):
|
|
||||||
prefix, suffix = '{', '}'
|
|
||||||
|
|
||||||
def write(self, fs, file, lineno, **row):
|
|
||||||
return bonobo.FileWriter.write(
|
|
||||||
self, fs, file, lineno,
|
|
||||||
json.dumps(row)[1:-1]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
graph = bonobo.Graph(
|
|
||||||
bonobo.FileReader('coffeeshops.txt'),
|
|
||||||
split_one_to_map,
|
|
||||||
MyJsonWriter('coffeeshops.json', fs='fs.output'),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_services():
|
|
||||||
return {
|
|
||||||
'fs': bonobo.open_examples_fs('datasets'),
|
|
||||||
'fs.output': bonobo.open_fs(),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph, services=get_services())
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
import bonobo
|
|
||||||
|
|
||||||
|
|
||||||
def generate_data():
|
|
||||||
yield 'foo'
|
|
||||||
yield 'bar'
|
|
||||||
yield 'baz'
|
|
||||||
|
|
||||||
|
|
||||||
def uppercase(x: str):
|
|
||||||
return x.upper()
|
|
||||||
|
|
||||||
|
|
||||||
def output(x: str):
|
|
||||||
print(x)
|
|
||||||
|
|
||||||
|
|
||||||
graph = bonobo.Graph(
|
|
||||||
generate_data,
|
|
||||||
uppercase,
|
|
||||||
output,
|
|
||||||
)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph)
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import bonobo
|
|
||||||
|
|
||||||
# Represent our data processor as a simple directed graph of callables.
|
|
||||||
graph = bonobo.Graph(
|
|
||||||
['foo', 'bar', 'baz'],
|
|
||||||
str.upper,
|
|
||||||
print,
|
|
||||||
)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
bonobo.run(graph)
|
|
||||||
@ -5,7 +5,19 @@ There are a few examples bundled with **bonobo**.
|
|||||||
|
|
||||||
You'll find them under the :mod:`bonobo.examples` package, and you can run them directly as modules:
|
You'll find them under the :mod:`bonobo.examples` package, and you can run them directly as modules:
|
||||||
|
|
||||||
$ bonobo run -m bonobo.examples...module
|
.. code-block:: shell-session
|
||||||
|
|
||||||
|
$ bonobo run -m bonobo.examples.module
|
||||||
|
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
.. code-block:: shell-session
|
||||||
|
|
||||||
|
$ python -m bonobo.examples.module
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 4
|
:maxdepth: 4
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
Examples from the tutorial
|
|
||||||
==========================
|
|
||||||
|
|
||||||
Examples from :doc:`/tutorial/tut01`
|
|
||||||
::::::::::::::::::::::::::::::::::::
|
|
||||||
|
|
||||||
Example 1
|
|
||||||
---------
|
|
||||||
|
|
||||||
.. automodule:: bonobo.examples.tutorials.tut01e01
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
Example 2
|
|
||||||
---------
|
|
||||||
|
|
||||||
.. automodule:: bonobo.examples.tutorials.tut01e02
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
Examples from :doc:`/tutorial/tut02`
|
|
||||||
::::::::::::::::::::::::::::::::::::
|
|
||||||
|
|
||||||
Example 1: Read
|
|
||||||
---------------
|
|
||||||
|
|
||||||
.. automodule:: bonobo.examples.tutorials.tut02e01_read
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
Example 2: Write
|
|
||||||
----------------
|
|
||||||
|
|
||||||
.. automodule:: bonobo.examples.tutorials.tut02e02_write
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
Example 3: Write as map
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
.. automodule:: bonobo.examples.tutorials.tut02e03_writeasmap
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user