MCPcopy
hub / github.com/httpie/cli / format_body

Method format_body

httpie/output/formatters/xml.py:59–79  ·  view source on GitHub ↗
(self, body: str, mime: str)

Source from the content-addressed store, hash-verified

57 self.enabled = self.format_options['xml']['format']
58
59 def format_body(self, body: str, mime: str):
60 if 'xml' not in mime:
61 return body
62
63 from xml.parsers.expat import ExpatError
64 from defusedxml.common import DefusedXmlException
65
66 declaration = parse_declaration(body)
67 try:
68 parsed_body = parse_xml(body)
69 except ExpatError:
70 pass # Invalid XML, ignore.
71 except DefusedXmlException:
72 pass # Unsafe XML, ignore.
73 else:
74 body = pretty_xml(parsed_body,
75 encoding=parsed_body.encoding,
76 indent=self.format_options['xml']['indent'],
77 declaration=declaration)
78
79 return body

Callers

nothing calls this directly

Calls 3

parse_declarationFunction · 0.85
parse_xmlFunction · 0.85
pretty_xmlFunction · 0.85

Tested by

no test coverage detected