[config] Refactoring of configurables, allowing partially configured objects.

Configurables did not allow more than one "method" option, and mixed
scenarios (options+methods+...) were sometimes flaky, forcing the user
to know what order was the right one. Now, all options work the same,
sharing the same "order" namespace.

Backward incompatible change: Options are now required by default,
unless a default is provided.

Also adds a few candies for debugging/testing, found in the
bonobo.util.inspect module.
This commit is contained in:
Romain Dorgueil
2017-07-05 11:15:03 +02:00
parent 67b4227436
commit 5062221e78
19 changed files with 573 additions and 120 deletions

View File

@ -1,16 +1,16 @@
import functools
from pprint import pprint as _pprint
import itertools
from colorama import Fore, Style
from bonobo import settings
from bonobo.config import Configurable, Option
from bonobo.config.processors import ContextProcessor
from bonobo.constants import NOT_MODIFIED
from bonobo.structs.bags import Bag
from bonobo.util.compat import deprecated
from bonobo.util.objects import ValueHolder
from bonobo.util.term import CLEAR_EOL
from bonobo.constants import NOT_MODIFIED
__all__ = [
'identity',
@ -87,8 +87,12 @@ class PrettyPrinter(Configurable):
)
pprint = PrettyPrinter()
pprint.__name__ = 'pprint'
_pprint = PrettyPrinter()
@deprecated
def pprint(*args, **kwargs):
return _pprint(*args, **kwargs)
def PrettyPrint(title_keys=('title', 'name', 'id'), print_values=True, sort=True):