Added function for pretty printing JSON Signed-off-by: Imesh Gunaratne <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/822454e0 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/822454e0 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/822454e0 Branch: refs/heads/stratos-4.1.x Commit: 822454e0b4d8d837753c795f808bbb66d0bb7972 Parents: a0c8f35 Author: Milindu Sanoj Kumarage <[email protected]> Authored: Thu Aug 6 10:15:41 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:48 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/cli/Utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/822454e0/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py b/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py index 96cc5ff..43ad375 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py @@ -18,6 +18,7 @@ from __future__ import print_function import sys from texttable import * +import json import Configs from Logging import logging @@ -68,6 +69,15 @@ class PrintableTable(Texttable): def print_table(self): print(self.draw()) +class PrintableJSON(Texttable): + + def __init__(self, json): + self.json = json + + def pprint(self): + + print(json.dumps(self.json, indent=4, separators=(',', ': '))) + def auth(func): """Authenticate""" def auth_inner(self, *args, **kwargs):
