from operator import itemgetter
from urllib import urlencode, quote
from jinja.utils import urlize, escape, reversed, sorted, groupby, \
- get_attribute
+ get_attribute, pformat
from jinja.datastructure import TemplateData
from jinja.exceptions import FilterArgumentError, SecurityException
Pretty print a variable. Useful for debugging.
"""
def wrapped(env, context, value):
- from pprint import pformat
return pformat(value)
return wrapped
del _test_singleton, _test_gen_bug
+def pformat(obj):
+ """
+ Prettyprint an object. Either use the `pp` library or the
+ builtin `pprint`.
+ """
+ try:
+ from pp import pp as format
+ except ImportError:
+ from pprint import pformat as format
+ return format(obj)
+
+
def buffereater(f):
"""
Used by the python translator to capture output of substreams.
def __call__(self, env, context):
"""Print a nice representation of the context."""
- from pprint import pformat
return pformat(context.to_dict())
def filters(self, env, context, builtins=True):