[nodes] Adds arg0_to_kwargs and kwargs_to_arg0 transformations.
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
from bonobo.structs import Bag, Graph, Token
|
from bonobo.structs import Bag, Graph, Token
|
||||||
from bonobo.nodes import CsvReader, CsvWriter, FileReader, FileWriter, Filter, JsonReader, JsonWriter, Limit, \
|
from bonobo.nodes import CsvReader, CsvWriter, FileReader, FileWriter, Filter, JsonReader, JsonWriter, Limit, \
|
||||||
PrettyPrinter, PickleWriter, PickleReader, RateLimited, Tee, count, identity, noop
|
PrettyPrinter, PickleWriter, PickleReader, RateLimited, Tee, count, identity, noop, arg0_to_kwargs, kwargs_to_arg0
|
||||||
from bonobo.strategies import create_strategy
|
from bonobo.strategies import create_strategy
|
||||||
from bonobo.util.objects import get_name
|
from bonobo.util.objects import get_name
|
||||||
|
|
||||||
@ -101,13 +101,15 @@ register_api_group(
|
|||||||
JsonReader,
|
JsonReader,
|
||||||
JsonWriter,
|
JsonWriter,
|
||||||
Limit,
|
Limit,
|
||||||
PrettyPrinter,
|
|
||||||
PickleReader,
|
PickleReader,
|
||||||
PickleWriter,
|
PickleWriter,
|
||||||
|
PrettyPrinter,
|
||||||
RateLimited,
|
RateLimited,
|
||||||
Tee,
|
Tee,
|
||||||
|
arg0_to_kwargs,
|
||||||
count,
|
count,
|
||||||
identity,
|
identity,
|
||||||
|
kwargs_to_arg0,
|
||||||
noop,
|
noop,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -91,8 +91,22 @@ def noop(*args, **kwargs): # pylint: disable=unused-argument
|
|||||||
|
|
||||||
|
|
||||||
def arg0_to_kwargs(row):
|
def arg0_to_kwargs(row):
|
||||||
|
"""
|
||||||
|
Transform items in a stream from "arg0" format (each call only has one positional argument, which is a dict-like
|
||||||
|
object) to "kwargs" format (each call only has keyword arguments that represent a row).
|
||||||
|
|
||||||
|
:param row:
|
||||||
|
:return: bonobo.Bag
|
||||||
|
"""
|
||||||
return Bag(**row)
|
return Bag(**row)
|
||||||
|
|
||||||
|
|
||||||
def kwargs_to_arg0(**row):
|
def kwargs_to_arg0(**row):
|
||||||
|
"""
|
||||||
|
Transform items in a stream from "kwargs" format (each call only has keyword arguments that represent a row) to
|
||||||
|
"arg0" format (each call only has one positional argument, which is a dict-like object) .
|
||||||
|
|
||||||
|
:param **row:
|
||||||
|
:return: bonobo.Bag
|
||||||
|
"""
|
||||||
return Bag(row)
|
return Bag(row)
|
||||||
|
|||||||
Reference in New Issue
Block a user