Source code for now.thirdparty.PyInquirer.utils
# -*- coding: utf-8 -*-
import json
__version__ = '0.1.2'
[docs]def colorize_json(data):
try:
from pygments import formatters, highlight, lexers
if isinstance(data, bytes):
data = data.decode('UTF-8')
colorful_json = highlight(
data, lexers.JsonLexer(), formatters.TerminalFormatter()
)
return colorful_json
except ModuleNotFoundError:
return data
[docs]def print_json(data):
# colorful_json = highlight(unicode(format_json(data), 'UTF-8'),
# lexers.JsonLexer(),
# formatters.TerminalFormatter())
print(colorize_json(format_json(data)))