[nodes] Removes old pretty printers (bonobo.pprint, bonobo.PrettyPrint) in favor of simpler bonobo.PrettyPrinter implementation. /!\ BC break /!\
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, pprint
|
PrettyPrinter, PickleWriter, PickleReader, RateLimited, Tee, count, identity, noop
|
||||||
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
|
||||||
|
|
||||||
@ -109,7 +109,6 @@ register_api_group(
|
|||||||
count,
|
count,
|
||||||
identity,
|
identity,
|
||||||
noop,
|
noop,
|
||||||
pprint,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from colorama import Fore, Style
|
|
||||||
|
|
||||||
from bonobo import settings
|
from bonobo import settings
|
||||||
from bonobo.config import Configurable, Option
|
from bonobo.config import Configurable, Option
|
||||||
from bonobo.config.processors import ContextProcessor
|
from bonobo.config.processors import ContextProcessor
|
||||||
from bonobo.constants import NOT_MODIFIED
|
from bonobo.constants import NOT_MODIFIED
|
||||||
from bonobo.structs.bags import Bag
|
from bonobo.structs.bags import Bag
|
||||||
from bonobo.util.compat import deprecated
|
|
||||||
from bonobo.util.objects import ValueHolder
|
from bonobo.util.objects import ValueHolder
|
||||||
from bonobo.util.term import CLEAR_EOL
|
from bonobo.util.term import CLEAR_EOL
|
||||||
|
|
||||||
@ -17,7 +14,6 @@ __all__ = [
|
|||||||
'Limit',
|
'Limit',
|
||||||
'Tee',
|
'Tee',
|
||||||
'count',
|
'count',
|
||||||
'pprint',
|
|
||||||
'PrettyPrinter',
|
'PrettyPrinter',
|
||||||
'noop',
|
'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
|
def noop(*args, **kwargs): # pylint: disable=unused-argument
|
||||||
from bonobo.constants import NOT_MODIFIED
|
from bonobo.constants import NOT_MODIFIED
|
||||||
return NOT_MODIFIED
|
return NOT_MODIFIED
|
||||||
|
|||||||
Reference in New Issue
Block a user