Skip to content
Myr

improved pprint

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent c6a3652 · Browse files · 2 files+11 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−7 removed

  • other:+11 added−7 removed

2 files+11 added−7 removed

modified:jinja/filters.py+5 added-2 removed
421 unmodified lines
422 return "%.1f GB" % (bytes / (1024 * 1024 * 1024))423 return wrapped424425426def do_pprint():426def do_pprint(verbose=False):427 """428 Pretty print a variable. Useful for debugging.429430 With Jinja 1.2 onwards you can pass it a parameter. If this parameter431 is truthy the output will be more verbose (this requires `pp`)432 """433 def wrapped(env, context, value):431 return pformat(value)434 return pformat(value, verbose=verbose)435 return wrapped436437438def do_urlize(value, trim_url_limit=None, nofollow=False):
548 unmodified lines
modified:jinja/utils.py+6 added-5 removed
348 unmodified lines
349 RUNTIME_EXCEPTION_OFFSET = 2350del _test_singleton, _test_gen_bug351352353def pformat(obj):353def pformat(obj, verbose=False):354 """355 Prettyprint an object. Either use the `pp` library or the356 builtin `pprint`.357 """358 try:359 from pp import pp as format359 from pp import pp360 return pp(obj, verbose=verbose)361 except ImportError:361 from pprint import pformat as format362 return format(obj)362 from pprint import pformat363 return pformat(obj)364365366def buffereater(f):367 """
51 unmodified lines
419 self.__class__.__name__)420421 def __call__(self, env, context):422 """Print a nice representation of the context."""422 return pformat(context.to_dict())423 return pformat(context.to_dict(), verbose=True)424425 def filters(self, env, context, builtins=True):426 """List the filters."""427 from inspect import getdoc
213 unmodified lines