Fix #249: Quoting format is integer, not string.

This commit is contained in:
Romain Dorgueil
2018-02-03 17:11:23 +01:00
parent aa6e426768
commit 02eeaff883
19 changed files with 68 additions and 47 deletions

View File

@ -47,15 +47,7 @@ class ConfigurableMeta(type):
prefix = ':param {}: '.format(_param)
for lineno, line in enumerate((_value.__doc__ or '').split('\n')):
_options_doc.append((' ' * len(prefix) if lineno else prefix) + line)
cls.__doc__ = '\n\n'.join(
map(
str.strip,
filter(None, (
cls.__doc__,
'\n'.join(_options_doc)
))
)
)
cls.__doc__ = '\n\n'.join(map(str.strip, filter(None, (cls.__doc__, '\n'.join(_options_doc)))))
@property
def __options__(cls):

View File

@ -56,7 +56,7 @@ class ETLCommand(BaseCommand):
graph_coll = self.get_graph(*args, **options)
if not isinstance(graph_coll, GeneratorType):
graph_coll = (graph_coll,)
graph_coll = (graph_coll, )
for i, graph in enumerate(graph_coll):
assert isinstance(graph, bonobo.Graph), 'Invalid graph provided.'

View File

@ -12,9 +12,11 @@ class FileHandler(Configurable):
encoding (str): which encoding to use when opening the file.
"""
path = Option(str, required=True, positional=True, __doc__='''
path = Option(
str, required=True, positional=True, __doc__='''
Path to use within the provided filesystem.
''') # type: str
'''
) # type: str
eol = Option(str, default='\n', __doc__='''
Character to use as line separator.
''') # type: str

View File

@ -33,7 +33,7 @@ class CsvHandler(FileHandler):
doublequote = Option(str, default=csv.excel.doublequote, required=False)
skipinitialspace = Option(str, default=csv.excel.skipinitialspace, required=False)
lineterminator = Option(str, default=csv.excel.lineterminator, required=False)
quoting = Option(str, default=csv.excel.quoting, required=False)
quoting = Option(int, default=csv.excel.quoting, required=False)
# Fields (renamed from headers)
headers = RenamedOption('fields')
@ -57,9 +57,13 @@ class CsvReader(FileReader, CsvHandler):
Reads a CSV and yield the values as dicts.
"""
skip = Option(int, default=0, __doc__='''
skip = Option(
int,
default=0,
__doc__='''
If set and greater than zero, the reader will skip this amount of lines.
''')
'''
)
@Method(
positional=False,

View File

@ -151,7 +151,10 @@ class Graph:
return '<strong>{}</strong>: {}'.format(type(exc).__name__, str(exc))
def _resolve_index(self, mixed):
""" Find the index based on various strategies for a node, probably an input or output of chain. Supported inputs are indexes, node values or names.
"""
Find the index based on various strategies for a node, probably an input or output of chain. Supported
inputs are indexes, node values or names.
"""
if mixed is None:
return None

View File

@ -14,8 +14,8 @@ class ApiHelper:
from inspect import signature
parameters = list(signature(x).parameters)
required_parameters = {'plugins', 'services', 'strategy'}
assert len(parameters) > 0 and parameters[
0] == 'graph', 'First parameter of a graph api function must be "graph".'
assert len(parameters
) > 0 and parameters[0] == 'graph', 'First parameter of a graph api function must be "graph".'
assert required_parameters.intersection(
parameters
) == required_parameters, 'Graph api functions must define the following parameters: ' + ', '.join(

View File

@ -26,7 +26,7 @@ def ensure_tuple(tuple_or_mixed, *, cls=tuple):
if isinstance(tuple_or_mixed, tuple):
return tuple.__new__(cls, tuple_or_mixed)
return tuple.__new__(cls, (tuple_or_mixed,))
return tuple.__new__(cls, (tuple_or_mixed, ))
def cast(type_):