import json
import client.swagger

__author__ = 'thauser'

base_pnc_url = "http://localhost:8080/pnc-rest/rest"
apiclient = client.swagger.ApiClient(base_pnc_url)


def _remove_nulls(input_json):
    keys = input_json.keys()
    if keys:
        for k in keys:
            if input_json[k] == None:
                del input_json[k]


def pretty_format_response(function, input_json):
    """
    prints the json dump in a more readable format.
    does not print null values
    :param input_json:
    :return:
    """
    if function is None:
        if type(input_json) is list:
            for item in input_json:
                _remove_nulls(item)
        else:
            _remove_nulls(input_json)
        return json.dumps(input_json, indent=4, separators=[",", ": "], sort_keys=True)
    else:
        return function(input_json)


def get_api_client():
    return apiclient
@@ -538,24 +538,158 @@
 s None:%0A    
+    return pretty_format_response(input_json)%0A    else:%0A        return function(input_json)%0A%0A%0Adef pretty_format_response(input_json):%0A
     if type(
@@ -709,20 +709,16 @@
 s list:%0A
-    
         
@@ -745,36 +745,32 @@
 on:%0A            
- 
-   
 _remove_nulls(it
@@ -777,30 +777,22 @@
 em)%0A    
-   
- 
 else:%0A
-    
         
@@ -817,28 +817,24 @@
 t_json)%0A    
- 
-   
 return json.
@@ -905,55 +905,8 @@
 ue)%0A
-    else:%0A        return function(input_json)%0A%0A
 %0Adef

add old method for now so no backward compat is needed