wip: filesystem as a service.
This commit is contained in:
@ -1,16 +1,21 @@
|
||||
from os.path import dirname, realpath, join
|
||||
|
||||
import bonobo
|
||||
from bonobo.ext.opendatasoft import OpenDataSoftAPI
|
||||
|
||||
OUTPUT_FILENAME = realpath(join(dirname(__file__), 'coffeeshops.txt'))
|
||||
filename = 'coffeeshops.txt'
|
||||
|
||||
graph = bonobo.Graph(
|
||||
OpenDataSoftAPI(dataset='liste-des-cafes-a-un-euro', netloc='opendata.paris.fr'),
|
||||
lambda row: '{nom_du_cafe}, {adresse}, {arrondissement} Paris, France'.format(**row),
|
||||
bonobo.FileWriter(path=OUTPUT_FILENAME),
|
||||
bonobo.FileWriter(path=filename),
|
||||
)
|
||||
|
||||
|
||||
def get_services():
|
||||
from os.path import dirname
|
||||
return {
|
||||
'fs': bonobo.open_fs(dirname(__file__))
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph)
|
||||
print('Import done, read {} for results.'.format(OUTPUT_FILENAME))
|
||||
bonobo.run(graph, services=get_services())
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from bonobo import JsonWriter, Graph, get_examples_path
|
||||
from bonobo.basics import Tee
|
||||
from bonobo.ext.opendatasoft import OpenDataSoftAPI
|
||||
|
||||
from colorama import Fore, Style
|
||||
|
||||
import bonobo
|
||||
from bonobo.ext.opendatasoft import OpenDataSoftAPI
|
||||
|
||||
try:
|
||||
import pycountry
|
||||
except ImportError as exc:
|
||||
@ -15,8 +14,6 @@ API_DATASET = 'fablabs-in-the-world'
|
||||
API_NETLOC = 'datanova.laposte.fr'
|
||||
ROWS = 100
|
||||
|
||||
__path__ = os.path.dirname(__file__)
|
||||
|
||||
|
||||
def _getlink(x):
|
||||
return x.get('url', None)
|
||||
@ -55,15 +52,21 @@ def display(row):
|
||||
print(' - {}source{}: {source}'.format(Fore.BLUE, Style.RESET_ALL, source='datanova/' + API_DATASET))
|
||||
|
||||
|
||||
graph = Graph(
|
||||
graph = bonobo.Graph(
|
||||
OpenDataSoftAPI(dataset=API_DATASET, netloc=API_NETLOC, timezone='Europe/Paris'),
|
||||
normalize,
|
||||
filter_france,
|
||||
Tee(display),
|
||||
JsonWriter(path=get_examples_path('datasets/fablabs.txt')),
|
||||
bonobo.Tee(display),
|
||||
bonobo.JsonWriter(path='datasets/fablabs.txt'),
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
from bonobo import run
|
||||
|
||||
run(graph)
|
||||
def get_services():
|
||||
from os.path import dirname
|
||||
return {
|
||||
'fs': bonobo.open_fs(dirname(__file__))
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph, services=get_services())
|
||||
|
||||
Reference in New Issue
Block a user