a_frame/utils/action_providers/RestAction.py
def __format_results(results):
        """
        detects string format (xml || json) and formats appropriately

        :param results: string from urlopen
        :return: formatted string output
        """
        if results is None:
            print("no actual results to process")
            return results

        # use pretty_print(if we have an xml document returned)
        try:
            if type(results) == "str" and results.startswith("<?xml"):
                print("Found XML results - using pretty_print")
                print(results)
                xml = etree.fromstring(results)
                return etree.tostring(xml, pretty_print=True)
        except etree.XMLSyntaxError:
            print("Invalid XML response")
            return results

        # is the result valid json?
        try:
            json_string = json.loads(results)
            print("Found JSON results")
            return json.dumps(json_string, indent=4)
        except ValueError:
            # this isn't xml or json, so just return it!
            print("Unknown results!")
            return results

        detects string format (xml || json) and formats appropriately

        :param results: string from urlopen
        :return: formatted string output
        
detects string format (xml || json) and formats appropriately
detects string format ( xml || json ) and formats appropriately
def __format_results(results):
        if results is None:
            print("no actual results to process")
            return results
        try:
            if type(results) == "str" and results.startswith("<?xml"):
                print("Found XML results - using pretty_print")
                print(results)
                xml = etree.fromstring(results)
                return etree.tostring(xml, pretty_print=True)
        except etree.XMLSyntaxError:
            print("Invalid XML response")
            return results
        try:
            json_string = json.loads(results)
            print("Found JSON results")
            return json.dumps(json_string, indent=4)
        except ValueError:
            print("Unknown results!")
            return results
def __format_results ( results ) : if results is None : print ( "no actual results to process" ) return results try : if type ( results ) == "str" and results . startswith ( "<?xml" ) : print ( "Found XML results - using pretty_print" ) print ( results ) xml = etree . fromstring ( results ) return etree . tostring ( xml , pretty_print = True ) except etree . XMLSyntaxError : print ( "Invalid XML response" ) return results try : json_string = json . loads ( results ) print ( "Found JSON results" ) return json . dumps ( json_string , indent = 4 ) except ValueError : print ( "Unknown results!" ) return results
detects string format (xml || json) and formats appropriately
detects string format ( xml || json ) and formats appropriately
"""
        detects string format (xml || json) and formats appropriately

        :param results: string from urlopen
        :return: formatted string output
        """ # use pretty_print(if we have an xml document returned) # is the result valid json? # this isn't xml or json, so just return it!
formatted string output
formatted string output
results
string from urlopen
string from urlopen