"""Various utility functions and classes not specific to any single area."""
+import cStringIO
import json
import logging
import logging.handlers
json.dump(data, f, **kwargs)
+def format_json(data, dense):
+ """Returns a string with json encoded data.
+
+ If dense is True, the json is packed. Otherwise, it is human readable.
+ """
+ buf = cStringIO.StringIO()
+ write_json(buf, data, dense)
+ return buf.getvalue()
+
+
def report_error(error):
"""Prints a error to stderr, wrapping it into header and footer.