[nodes] Removes old pretty printers (bonobo.pprint, bonobo.PrettyPrint) in favor of simpler bonobo.PrettyPrinter implementation. /!\ BC break /!\

This commit is contained in:
Romain Dorgueil
2017-07-05 11:52:47 +02:00
parent 2ff19c18a6
commit 0bcdbd70ab
2 changed files with 1 additions and 51 deletions

View File

@ -1,14 +1,11 @@
import functools
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
@ -17,7 +14,6 @@ __all__ = [
'Limit',
'Tee',
'count',
'pprint',
'PrettyPrinter',
'noop',
]
@ -87,51 +83,6 @@ class PrettyPrinter(Configurable):
)
_pprint = PrettyPrinter()
@deprecated
def pprint(*args, **kwargs):
return _pprint(*args, **kwargs)
def PrettyPrint(title_keys=('title', 'name', 'id'), print_values=True, sort=True):
from bonobo.constants import NOT_MODIFIED
def _pprint(*args, **kwargs):
nonlocal title_keys, sort, print_values
row = args[0]
for key in title_keys:
if key in row:
print(Style.BRIGHT, row.get(key), Style.RESET_ALL, sep='')
break
if print_values:
for k in sorted(row) if sort else row:
print(
'',
Fore.BLUE,
k,
Style.RESET_ALL,
' : ',
Fore.BLACK,
'(',
type(row[k]).__name__,
')',
Style.RESET_ALL,
' ',
repr(row[k]),
CLEAR_EOL,
)
yield NOT_MODIFIED
_pprint.__name__ = 'pprint'
return _pprint
def noop(*args, **kwargs): # pylint: disable=unused-argument
from bonobo.constants import NOT_MODIFIED
return NOT_MODIFIED