Working toward sqlalchemy extension. Better ability to extend context. Still needs a lot of cleanup.

This commit is contained in:
Romain Dorgueil
2017-01-03 22:06:09 +01:00
parent 6bfe751c73
commit f736e7e7e3
27 changed files with 387 additions and 142 deletions

View File

@ -53,9 +53,10 @@ class ConsoleOutputPlugin(Plugin):
def _write(self, context, rewind):
profile, debug = False, False
if profile:
append = (('Memory', '{0:.2f} Mb'.format(memory_usage())),
# ('Total time', '{0} s'.format(execution_time(harness))),
)
append = (
('Memory', '{0:.2f} Mb'.format(memory_usage())),
# ('Total time', '{0} s'.format(execution_time(harness))),
)
else:
append = ()
self.write(context, prefix=self.prefix, append=append, debug=debug, profile=profile, rewind=rewind)
@ -77,25 +78,35 @@ class ConsoleOutputPlugin(Plugin):
for i, component in enumerate(context):
if component.alive:
_line = ''.join((
t.black('({})'.format(i + 1)),
' ',
t.bold(t.white('+')),
' ',
component.name,
' ',
component.get_stats_as_string(
debug=debug, profile=profile),
' ', ))
_line = ''.join(
(
t.black('({})'.format(i + 1)),
' ',
t.bold(t.white('+')),
' ',
component.name,
' ',
component.get_stats_as_string(
debug=debug, profile=profile
),
' ',
)
)
else:
_line = t.black(''.join((
'({})'.format(i + 1),
' - ',
component.name,
' ',
component.get_stats_as_string(
debug=debug, profile=profile),
' ', )))
_line = t.black(
''.join(
(
'({})'.format(i + 1),
' - ',
component.name,
' ',
component.get_stats_as_string(
debug=debug, profile=profile
),
' ',
)
)
)
print(prefix + _line + t.clear_eol)
if append:

View File

@ -6,9 +6,11 @@ try:
except ImportError as e:
import logging
logging.exception('You must install Jupyter to use the bonobo Jupyter extension. Easiest way is to install the '
'optional "jupyter" dependencies with «pip install bonobo[jupyter]», but you can also install a '
'specific version by yourself.')
logging.exception(
'You must install Jupyter to use the bonobo Jupyter extension. Easiest way is to install the '
'optional "jupyter" dependencies with «pip install bonobo[jupyter]», but you can also install a '
'specific version by yourself.'
)
class JupyterOutputPlugin(Plugin):

View File

@ -3,17 +3,20 @@ from urllib.parse import urlencode
import requests # todo: make this a service so we can substitute it ?
def from_opendatasoft_api(dataset=None,
endpoint='{scheme}://{netloc}{path}',
scheme='https',
netloc='data.opendatasoft.com',
path='/api/records/1.0/search/',
rows=100,
**kwargs):
def from_opendatasoft_api(
dataset=None,
endpoint='{scheme}://{netloc}{path}',
scheme='https',
netloc='data.opendatasoft.com',
path='/api/records/1.0/search/',
rows=100,
**kwargs
):
path = path if path.startswith('/') else '/' + path
params = (
('dataset', dataset),
('rows', rows), ) + tuple(sorted(kwargs.items()))
('rows', rows),
) + tuple(sorted(kwargs.items()))
base_url = endpoint.format(scheme=scheme, netloc=netloc, path=path) + '?' + urlencode(params)
def _extract_ods():