adds yapf for automatic style.

This commit is contained in:
Romain Dorgueil
2016-12-24 10:57:47 +01:00
parent 14d6d2c0dd
commit b1880b42f9
13 changed files with 48 additions and 57 deletions

View File

@ -26,13 +26,14 @@ t = blessings.Terminal()
@lru_cache(1)
def memory_usage():
process = psutil.Process(os.getpid())
return process.get_memory_info()[0] / float(2 ** 20)
return process.get_memory_info()[0] / float(2**20)
# @lru_cache(64)
# def execution_time(harness):
# return datetime.datetime.now() - harness._started_at
class ConsoleOutputPlugin:
"""
Outputs status information to the connected stdout. Can be a TTY, with or without support for colors/cursor
@ -50,10 +51,9 @@ class ConsoleOutputPlugin:
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)
@ -76,24 +76,24 @@ class ConsoleOutputPlugin:
for i, component in enumerate(context):
if component.running:
_line = ''.join((
t.black('({})'.format(i+1)),
t.black('({})'.format(i + 1)),
' ',
t.bold(t.white('+')),
' ',
component.name,
' ',
component.get_stats_as_string(debug=debug, profile=profile),
' ',
))
component.get_stats_as_string(
debug=debug, profile=profile),
' ', ))
else:
_line = t.black(''.join((
'({})'.format(i+1),
'({})'.format(i + 1),
' - ',
component.name,
' ',
component.get_stats_as_string(debug=debug, profile=profile),
' ',
)))
component.get_stats_as_string(
debug=debug, profile=profile),
' ', )))
print(prefix + _line + t.clear_eol)
if append:

View File

@ -17,7 +17,9 @@ from bonobo import service
@service
def client(username, password):
client = couchdb.Server()
client.resource.credentials = (username, password,)
client.resource.credentials = (
username,
password, )
return client

View File

@ -3,12 +3,7 @@ from .plugin import JupyterOutputPlugin
def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
'src': 'static',
'dest': 'bonobo-jupyter',
'require': 'bonobo-jupyter/extension'
}]
return [{'section': 'notebook', 'src': 'static', 'dest': 'bonobo-jupyter', 'require': 'bonobo-jupyter/extension'}]
__all__ = [

View File

@ -4,7 +4,9 @@ import requests # todo: make this a service so we can substitute it ?
def extract_ods(url, dataset, rows=100, **kwargs):
params = (('dataset', dataset), ('rows', rows),) + tuple(sorted(kwargs.items()))
params = (
('dataset', dataset),
('rows', rows), ) + tuple(sorted(kwargs.items()))
base_url = url + '?' + urlencode(params)
def _extract_ods():
@ -18,10 +20,7 @@ def extract_ods(url, dataset, rows=100, **kwargs):
break
for row in records:
yield {
**row.get('fields', {}),
'geometry': row.get('geometry', {})
}
yield { ** row.get('fields', {}), 'geometry': row.get('geometry', {})}
start += rows