Making config/util/structs apis available at level 2 import (x.y), implements the roots for loopbacks (recursive transformations). This still needs work, as its hard not to close an input queue as soon as the last item was read.
This commit is contained in:
@ -1,6 +1,28 @@
|
||||
from bonobo.util.inspect import (
|
||||
inspect_node,
|
||||
isbag,
|
||||
isconfigurable,
|
||||
isconfigurabletype,
|
||||
iscontextprocessor,
|
||||
iserrorbag,
|
||||
isloopbackbag,
|
||||
ismethod,
|
||||
isoption,
|
||||
istype,
|
||||
)
|
||||
from bonobo.util.python import require
|
||||
|
||||
# Bonobo's util API
|
||||
__all__ = [
|
||||
'require'
|
||||
'require',
|
||||
'inspect_node',
|
||||
'isbag',
|
||||
'isconfigurable',
|
||||
'isconfigurabletype',
|
||||
'iscontextprocessor',
|
||||
'iserrorbag',
|
||||
'isloopbackbag',
|
||||
'ismethod',
|
||||
'isoption',
|
||||
'istype',
|
||||
]
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import sys
|
||||
from textwrap import indent
|
||||
|
||||
from bonobo import settings
|
||||
from bonobo.structs.bags import ErrorBag
|
||||
|
||||
|
||||
def is_error(bag):
|
||||
return isinstance(bag, ErrorBag)
|
||||
|
||||
|
||||
def _get_error_message(exc):
|
||||
if hasattr(exc, '__str__'):
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
from collections import namedtuple
|
||||
|
||||
from bonobo.constants import LOOPBACK
|
||||
|
||||
|
||||
def isconfigurable(mixed):
|
||||
"""
|
||||
Check if the given argument is an instance of :class:`bonobo.config.Configurable`.
|
||||
|
||||
:param mixed:
|
||||
:return: bool
|
||||
"""
|
||||
from bonobo.config.configurables import Configurable
|
||||
return isinstance(mixed, Configurable)
|
||||
|
||||
|
||||
def isconfigurabletype(mixed):
|
||||
"""
|
||||
@ -13,17 +26,6 @@ def isconfigurabletype(mixed):
|
||||
return isinstance(mixed, ConfigurableMeta)
|
||||
|
||||
|
||||
def isconfigurable(mixed):
|
||||
"""
|
||||
Check if the given argument is an instance of :class:`bonobo.config.Configurable`.
|
||||
|
||||
:param mixed:
|
||||
:return: bool
|
||||
"""
|
||||
from bonobo.config.configurables import Configurable
|
||||
return isinstance(mixed, Configurable)
|
||||
|
||||
|
||||
def isoption(mixed):
|
||||
"""
|
||||
Check if the given argument is an instance of :class:`bonobo.config.Option`.
|
||||
@ -68,6 +70,38 @@ def istype(mixed):
|
||||
return isinstance(mixed, type)
|
||||
|
||||
|
||||
def isbag(mixed):
|
||||
"""
|
||||
Check if the given argument is an instance of a :class:`bonobo.Bag`.
|
||||
|
||||
:param mixed:
|
||||
:return: bool
|
||||
"""
|
||||
from bonobo.structs.bags import Bag
|
||||
return isinstance(mixed, Bag)
|
||||
|
||||
|
||||
def iserrorbag(mixed):
|
||||
"""
|
||||
Check if the given argument is an instance of an :class:`bonobo.ErrorBag`.
|
||||
|
||||
:param mixed:
|
||||
:return: bool
|
||||
"""
|
||||
from bonobo.structs.bags import ErrorBag
|
||||
return isinstance(mixed, ErrorBag)
|
||||
|
||||
|
||||
def isloopbackbag(mixed):
|
||||
"""
|
||||
Check if the given argument is an instance of a :class:`bonobo.Bag`, marked for loopback behaviour.
|
||||
|
||||
:param mixed:
|
||||
:return: bool
|
||||
"""
|
||||
return isbag(mixed) and LOOPBACK in mixed.flags
|
||||
|
||||
|
||||
ConfigurableInspection = namedtuple(
|
||||
'ConfigurableInspection', [
|
||||
'type',
|
||||
|
||||
Reference in New Issue
Block a user