release: 0.2.2

This commit is contained in:
Romain Dorgueil
2017-04-28 08:04:48 +02:00
parent 9a3fa98723
commit bb5fc22f5e
21 changed files with 56 additions and 63 deletions

View File

@ -24,7 +24,6 @@ from bonobo.strategies import create_strategy
__all__ += ['create_strategy']
# Extract and loads from stdlib.
from bonobo.io import *
from bonobo.io import __all__ as _all_io

View File

@ -1 +1 @@
__version__ = '0.2.1'
__version__ = '0.2.2'

View File

@ -59,7 +59,13 @@ def execute(file, quiet=False):
# todo if console and not quiet, then add the console plugin
# todo when better console plugin, add it if console and just disable display
return bonobo.run(graph, plugins=[], services=get_default_services(file.name, context.get(DEFAULT_SERVICES_ATTR)() if DEFAULT_SERVICES_ATTR in context else None))
return bonobo.run(
graph,
plugins=[],
services=get_default_services(
file.name, context.get(DEFAULT_SERVICES_ATTR)() if DEFAULT_SERVICES_ATTR in context else None
)
)
def register(parser):

View File

@ -11,6 +11,7 @@ def validate_service_name(name):
raise ValueError('Invalid service name {!r}.'.format(name))
return name
class Service(Option):
"""
A Service is a special kind of option defining a dependency to something that will be resolved at runtime, using an
@ -55,7 +56,7 @@ class Container(dict):
def __new__(cls, *args, **kwargs):
if len(args) == 1:
assert not len(kwargs), 'only one usage at a time, my dear.'
if not(args[0]):
if not (args[0]):
return super().__new__(cls)
if isinstance(args[0], cls):
return cls
@ -67,11 +68,7 @@ class Container(dict):
except AttributeError:
options = {}
return tuple(
option.resolve(mixed, self)
for name, option in options.items()
if isinstance(option, Service)
)
return tuple(option.resolve(mixed, self) for name, option in options.items() if isinstance(option, Service))
def get(self, name, default=None):
if not name in self:
@ -82,7 +79,3 @@ class Container(dict):
if isinstance(value, types.LambdaType):
value = value(self)
return value

View File

@ -1,2 +1 @@
""" Core required libraries. """

View File

@ -4,6 +4,4 @@ import bonobo
def get_services():
return {
'fs': bonobo.open_fs(dirname(__file__))
}
return {'fs': bonobo.open_fs(dirname(__file__))}

View File

@ -4,10 +4,7 @@ from bonobo.commands.run import get_default_services
# XXX does not work anymore because of filesystem service, can't read HTTP
url = 'https://data.toulouse-metropole.fr/explore/dataset/theatres-et-salles-de-spectacles/download?format=json&timezone=Europe/Berlin&use_labels_for_header=true'
graph = bonobo.Graph(
bonobo.JsonReader(path=url),
print
)
graph = bonobo.Graph(bonobo.JsonReader(path=url), print)
if __name__ == '__main__':
bonobo.run(graph, services=get_default_services(__file__))

View File

@ -2,6 +2,4 @@ from bonobo import get_examples_path, open_fs
def get_services():
return {
'fs': open_fs(get_examples_path())
}
return {'fs': open_fs(get_examples_path())}

View File

@ -8,10 +8,8 @@ graph = bonobo.Graph(
def get_services():
return {
'fs': bonobo.open_fs(bonobo.get_examples_path())
}
return {'fs': bonobo.open_fs(bonobo.get_examples_path())}
if __name__ == '__main__':
bonobo.run(graph, services=get_default_services(__file__, get_services()))

View File

@ -1,3 +1 @@
from bonobo.execution.graph import GraphExecutionContext, NodeExecutionContext, PluginExecutionContext

View File

@ -30,7 +30,8 @@ class LoopingExecutionContext(Wrapper):
if services:
if parent:
raise RuntimeError(
'Having services defined both in GraphExecutionContext and child NodeExecutionContext is not supported, for now.')
'Having services defined both in GraphExecutionContext and child NodeExecutionContext is not supported, for now.'
)
self.services = Container(services) if services else Container()
else:
self.services = None

View File

@ -55,7 +55,7 @@ class CsvReader(CsvHandler, FileReader):
for row in reader:
if len(row) != field_count:
raise ValueError('Got a line with %d fields, expecting %d.' % (len(row), field_count,))
raise ValueError('Got a line with %d fields, expecting %d.' % (len(row), field_count, ))
yield dict(zip(headers.value, row))

View File

@ -2,6 +2,4 @@ from bonobo.structs.bags import Bag
from bonobo.structs.graphs import Graph
from bonobo.structs.tokens import Token
__all__ = [
'Bag', 'Graph', 'Token'
]
__all__ = ['Bag', 'Graph', 'Token']

View File

@ -32,7 +32,8 @@ def deprecated_alias(alias, func):
warnings.simplefilter('always', DeprecationWarning) # turn off filter
warnings.warn(
"Call to deprecated function alias {}, use {} instead.".format(alias, func.__name__),
category=DeprecationWarning, stacklevel=2
category=DeprecationWarning,
stacklevel=2
)
warnings.simplefilter('default', DeprecationWarning) # reset filter
return func(*args, **kwargs)

View File

@ -20,10 +20,10 @@ def force_iterator(mixed):
def ensure_tuple(tuple_or_mixed):
if isinstance(tuple_or_mixed, tuple):
return tuple_or_mixed
return (tuple_or_mixed,)
return (tuple_or_mixed, )
def iter_if_not_sequence(mixed):
if isinstance(mixed, (dict, list, str)):
raise TypeError(type(mixed).__name__)
return iter(mixed)
return iter(mixed)