reformating code, and adding specific rules for examples so it shows up correctly on readthedocs, by default.
This commit is contained in:
@ -88,7 +88,15 @@ def open_fs(fs_url, *args, **kwargs):
|
||||
|
||||
|
||||
# bonobo.basics
|
||||
register_api_group(Limit, PrettyPrint, Tee, count, identity, noop, pprint, )
|
||||
register_api_group(
|
||||
Limit,
|
||||
PrettyPrint,
|
||||
Tee,
|
||||
count,
|
||||
identity,
|
||||
noop,
|
||||
pprint,
|
||||
)
|
||||
|
||||
# bonobo.io
|
||||
register_api_group(CsvReader, CsvWriter, FileReader, FileWriter, JsonReader, JsonWriter)
|
||||
@ -116,4 +124,3 @@ def get_examples_path(*pathsegments):
|
||||
@register_api
|
||||
def open_examples_fs(*pathsegments):
|
||||
return open_fs(get_examples_path(*pathsegments))
|
||||
|
||||
|
||||
@ -66,6 +66,7 @@ pprint = Tee(_pprint)
|
||||
|
||||
def PrettyPrint(title_keys=('title', 'name', 'id'), print_values=True, sort=True):
|
||||
from bonobo.constants import NOT_MODIFIED
|
||||
|
||||
def _pprint(*args, **kwargs):
|
||||
nonlocal title_keys, sort, print_values
|
||||
|
||||
|
||||
4
bonobo/examples/.style.yapf
Normal file
4
bonobo/examples/.style.yapf
Normal file
@ -0,0 +1,4 @@
|
||||
[style]
|
||||
based_on_style = pep8
|
||||
column_limit = 80
|
||||
dedent_closing_brackets = true
|
||||
@ -25,7 +25,9 @@ from bonobo.ext.opendatasoft import OpenDataSoftAPI
|
||||
try:
|
||||
import pycountry
|
||||
except ImportError as exc:
|
||||
raise ImportError('You must install package "pycountry" to run this example.') from exc
|
||||
raise ImportError(
|
||||
'You must install package "pycountry" to run this example.'
|
||||
) from exc
|
||||
|
||||
API_DATASET = 'fablabs-in-the-world'
|
||||
API_NETLOC = 'datanova.laposte.fr'
|
||||
@ -57,20 +59,38 @@ def display(row):
|
||||
address = list(
|
||||
filter(
|
||||
None, (
|
||||
' '.join(filter(None, (row.get('postal_code', None), row.get('city', None)))), row.get('county', None),
|
||||
row.get('country'),
|
||||
' '.join(
|
||||
filter(
|
||||
None,
|
||||
(row.get('postal_code', None), row.get('city', None))
|
||||
)
|
||||
), row.get('county', None), row.get('country'),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
print(' - {}address{}: {address}'.format(Fore.BLUE, Style.RESET_ALL, address=', '.join(address)))
|
||||
print(' - {}links{}: {links}'.format(Fore.BLUE, Style.RESET_ALL, links=', '.join(row['links'])))
|
||||
print(' - {}geometry{}: {geometry}'.format(Fore.BLUE, Style.RESET_ALL, **row))
|
||||
print(' - {}source{}: {source}'.format(Fore.BLUE, Style.RESET_ALL, source='datanova/' + API_DATASET))
|
||||
print(
|
||||
' - {}address{}: {address}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, address=', '.join(address))
|
||||
)
|
||||
print(
|
||||
' - {}links{}: {links}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, links=', '.join(row['links']))
|
||||
)
|
||||
print(
|
||||
' - {}geometry{}: {geometry}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, **row)
|
||||
)
|
||||
print(
|
||||
' - {}source{}: {source}'.
|
||||
format(Fore.BLUE, Style.RESET_ALL, source='datanova/' + API_DATASET)
|
||||
)
|
||||
|
||||
|
||||
graph = bonobo.Graph(
|
||||
OpenDataSoftAPI(dataset=API_DATASET, netloc=API_NETLOC, timezone='Europe/Paris'),
|
||||
OpenDataSoftAPI(
|
||||
dataset=API_DATASET, netloc=API_NETLOC, timezone='Europe/Paris'
|
||||
),
|
||||
normalize,
|
||||
filter_france,
|
||||
bonobo.Tee(display),
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import bonobo
|
||||
from bonobo.commands.run import get_default_services
|
||||
|
||||
|
||||
def get_fields(row):
|
||||
return row['fields']
|
||||
|
||||
|
||||
graph = bonobo.Graph(
|
||||
bonobo.JsonReader(path='datasets/theaters.json'),
|
||||
get_fields,
|
||||
|
||||
@ -6,6 +6,4 @@ graph = bonobo.Graph(
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph, services={
|
||||
'fs': bonobo.open_examples_fs('datasets')
|
||||
})
|
||||
bonobo.run(graph, services={'fs': bonobo.open_examples_fs('datasets')})
|
||||
|
||||
@ -12,6 +12,4 @@ graph = bonobo.Graph(
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph, services={
|
||||
'fs': bonobo.open_examples_fs('datasets')
|
||||
})
|
||||
bonobo.run(graph, services={'fs': bonobo.open_examples_fs('datasets')})
|
||||
|
||||
@ -22,6 +22,4 @@ graph = bonobo.Graph(
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph, services={
|
||||
'fs': bonobo.open_examples_fs('datasets')
|
||||
})
|
||||
bonobo.run(graph, services={'fs': bonobo.open_examples_fs('datasets')})
|
||||
|
||||
@ -22,5 +22,3 @@ class JupyterOutputPlugin(Plugin):
|
||||
self.widget.value = [repr(node) for node in self.context.parent.nodes]
|
||||
|
||||
finalize = run
|
||||
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ class ExecutorStrategy(Strategy):
|
||||
futures = []
|
||||
|
||||
for plugin_context in context.plugins:
|
||||
|
||||
def _runner(plugin_context=plugin_context):
|
||||
try:
|
||||
plugin_context.start()
|
||||
@ -45,8 +46,9 @@ class ExecutorStrategy(Strategy):
|
||||
try:
|
||||
node_context.start()
|
||||
except Exception as exc:
|
||||
print_error(exc, traceback.format_exc(), prefix='Could not start node context',
|
||||
context=node_context)
|
||||
print_error(
|
||||
exc, traceback.format_exc(), prefix='Could not start node context', context=node_context
|
||||
)
|
||||
node_context.input.on_end()
|
||||
else:
|
||||
node_context.loop()
|
||||
|
||||
@ -32,7 +32,7 @@ class Bag:
|
||||
foo notbaz
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, *args, _flags=None, _parent=None, **kwargs):
|
||||
self._flags = _flags or ()
|
||||
self._parent = _parent
|
||||
|
||||
@ -21,8 +21,9 @@ def print_error(exc, trace, context=None, prefix=''):
|
||||
print(
|
||||
Style.BRIGHT,
|
||||
Fore.RED,
|
||||
'\U0001F4A3 {}{}{}'.format((prefix + ': ') if prefix else '', type(exc).__name__,
|
||||
' in {!r}'.format(context) if context else ''),
|
||||
'\U0001F4A3 {}{}{}'.format(
|
||||
(prefix + ': ') if prefix else '', type(exc).__name__, ' in {!r}'.format(context) if context else ''
|
||||
),
|
||||
Style.RESET_ALL,
|
||||
sep='',
|
||||
file=sys.stderr,
|
||||
|
||||
32
setup.py
32
setup.py
@ -45,39 +45,37 @@ setup(
|
||||
description='Bonobo',
|
||||
license='Apache License, Version 2.0',
|
||||
install_requires=[
|
||||
'colorama >=0.3,<1.0', 'fs >=2.0,<3.0', 'psutil >=5.2,<6.0',
|
||||
'requests >=2.0,<3.0', 'stevedore >=1.21,<2.0'
|
||||
'colorama >=0.3,<1.0', 'fs >=2.0,<3.0', 'psutil >=5.2,<6.0', 'requests >=2.0,<3.0', 'stevedore >=1.21,<2.0'
|
||||
],
|
||||
version=version,
|
||||
long_description=read('README.rst'),
|
||||
classifiers=read('classifiers.txt', tolines),
|
||||
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
|
||||
include_package_data=True,
|
||||
data_files=[('share/jupyter/nbextensions/bonobo-jupyter', [
|
||||
'bonobo/ext/jupyter/static/extension.js',
|
||||
'bonobo/ext/jupyter/static/index.js',
|
||||
'bonobo/ext/jupyter/static/index.js.map'
|
||||
])],
|
||||
data_files=[
|
||||
(
|
||||
'share/jupyter/nbextensions/bonobo-jupyter', [
|
||||
'bonobo/ext/jupyter/static/extension.js', 'bonobo/ext/jupyter/static/index.js',
|
||||
'bonobo/ext/jupyter/static/index.js.map'
|
||||
]
|
||||
)
|
||||
],
|
||||
extras_require={
|
||||
'dev': [
|
||||
'coverage >=4,<5', 'pylint >=1,<2', 'pytest >=3,<4',
|
||||
'pytest-cov >=2,<3', 'pytest-timeout >=1,<2', 'sphinx',
|
||||
'coverage >=4,<5', 'pylint >=1,<2', 'pytest >=3,<4', 'pytest-cov >=2,<3', 'pytest-timeout >=1,<2', 'sphinx',
|
||||
'sphinx_rtd_theme', 'yapf'
|
||||
],
|
||||
'jupyter': ['jupyter >=1.0,<1.1', 'ipywidgets >=6.0.0.beta5']
|
||||
},
|
||||
entry_points={
|
||||
'bonobo.commands': [
|
||||
'init = bonobo.commands.init:register',
|
||||
'run = bonobo.commands.run:register',
|
||||
'init = bonobo.commands.init:register', 'run = bonobo.commands.run:register',
|
||||
'version = bonobo.commands.version:register'
|
||||
],
|
||||
'console_scripts': ['bonobo = bonobo.commands:entrypoint'],
|
||||
'edgy.project.features':
|
||||
['bonobo = '
|
||||
'bonobo.ext.edgy.project.feature:BonoboFeature']
|
||||
'edgy.project.features': ['bonobo = '
|
||||
'bonobo.ext.edgy.project.feature:BonoboFeature']
|
||||
},
|
||||
url='https://www.bonobo-project.org/',
|
||||
download_url=
|
||||
'https://github.com/python-bonobo/bonobo/tarball/{version}'.format(
|
||||
version=version), )
|
||||
download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'.format(version=version),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user