XML pretty-print in separate option

Who reads plain XML anyway?
This commit is contained in:
2015-02-20 17:38:39 +08:00
parent fcf4197801
commit ef946c0712
3 changed files with 7 additions and 4 deletions

View File

@@ -361,7 +361,7 @@ class FeedParser(FeedBase):
items = FeedListDescriptor('items')
def tostring(self, **k):
return etree.tostring(self.xml.getroottree(), pretty_print=True, **k)
return etree.tostring(self.xml.getroottree(), **k)
def tojson(self, indent=None):
return json.dumps(OrderedDict(self), indent=indent)

View File

@@ -631,7 +631,10 @@ def Format(rss, options):
elif options.reader:
return rss.tohtml()
else:
return rss.tostring(xml_declaration=True, encoding='UTF-8')
if options.indent:
return rss.tostring(xml_declaration=True, encoding='UTF-8', pretty_print=True)
else:
return rss.tostring(xml_declaration=True, encoding='UTF-8')
def process(url, cache=None, options=None):