Adds simple partial() function adding a .using(...) method to regular functools.partial object.
This commit is contained in:
@ -6,7 +6,6 @@ All objects in this module are considered very safe to use, and backward compati
|
|||||||
to another is maximal.
|
to another is maximal.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from bonobo.execution.strategies import create_strategy
|
from bonobo.execution.strategies import create_strategy
|
||||||
from bonobo.nodes import *
|
from bonobo.nodes import *
|
||||||
from bonobo.nodes import __all__ as _all_nodes
|
from bonobo.nodes import __all__ as _all_nodes
|
||||||
@ -196,3 +195,4 @@ def open_examples_fs(*pathsegments):
|
|||||||
|
|
||||||
|
|
||||||
api.register_group(get_argument_parser, parse_args)
|
api.register_group(get_argument_parser, parse_args)
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ configurable transformations, either class-based or function-based.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from bonobo.config.configurables import Configurable
|
from bonobo.config.configurables import Configurable
|
||||||
from bonobo.config.functools import transformation_factory
|
from bonobo.config.functools import transformation_factory, partial
|
||||||
from bonobo.config.options import Method, Option
|
from bonobo.config.options import Method, Option
|
||||||
from bonobo.config.processors import ContextProcessor, use_context, use_context_processor, use_raw_input, use_no_input
|
from bonobo.config.processors import ContextProcessor, use_context, use_context_processor, use_raw_input, use_no_input
|
||||||
from bonobo.config.services import Container, Exclusive, Service, use, create_container
|
from bonobo.config.services import Container, Exclusive, Service, use, create_container
|
||||||
@ -23,6 +23,7 @@ __all__ = [
|
|||||||
"Option",
|
"Option",
|
||||||
"Service",
|
"Service",
|
||||||
"create_container",
|
"create_container",
|
||||||
|
"partial",
|
||||||
"requires",
|
"requires",
|
||||||
"transformation_factory",
|
"transformation_factory",
|
||||||
"use",
|
"use",
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
from bonobo.config.services import use
|
||||||
|
from bonobo.util import get_name
|
||||||
|
|
||||||
|
|
||||||
def transformation_factory(f):
|
def transformation_factory(f):
|
||||||
@functools.wraps(f)
|
@functools.wraps(f)
|
||||||
@ -14,3 +17,11 @@ def transformation_factory(f):
|
|||||||
_transformation_factory._partial = True
|
_transformation_factory._partial = True
|
||||||
|
|
||||||
return _transformation_factory
|
return _transformation_factory
|
||||||
|
|
||||||
|
|
||||||
|
class partial(functools.partial):
|
||||||
|
@property
|
||||||
|
def __name__(self):
|
||||||
|
return get_name(self.func)
|
||||||
|
def using(self, *service_names):
|
||||||
|
return use(*service_names)(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user