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

        :param results: string from urlopen
        :return: formatted string output
        """
        # print results
        try:
            if type(results) is str:
                results = etree.fromstring(results)

            print "found valid xml, formatting and returning"
            # use pretty_print if we have an xml document returned
            return etree.tostring(results, pretty_print=True)
        except XMLSyntaxError:
            pass
        except ValueError:
            pass
        except TypeError:
            pass

        # is the result valid json?
        try:
            json_string = json.loads(results)
            print "Found JSON results"
            return json.dumps(json_string, indent=4)
        except ValueError:
            pass
        except TypeError:
            pass

        print "no special formatting, returning"
        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):
        try:
            if type(results) is str:
                results = etree.fromstring(results)
            print "found valid xml, formatting and returning"
            return etree.tostring(results, pretty_print=True)
        except XMLSyntaxError:
            pass
        except ValueError:
            pass
        except TypeError:
            pass
        try:
            json_string = json.loads(results)
            print "Found JSON results"
            return json.dumps(json_string, indent=4)
        except ValueError:
            pass
        except TypeError:
            pass
        print "no special formatting, returning"
        return results
def format_results ( results ) : try : if type ( results ) is str : results = etree . fromstring ( results ) print "found valid xml, formatting and returning" return etree . tostring ( results , pretty_print = True ) except XMLSyntaxError : pass except ValueError : pass except TypeError : pass try : json_string = json . loads ( results ) print "Found JSON results" return json . dumps ( json_string , indent = 4 ) except ValueError : pass except TypeError : pass print "no special formatting, returning" 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
        """ # print results # use pretty_print if we have an xml document returned # is the result valid json?
formatted string output
formatted string output
results
string from urlopen
string from urlopen