File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,11 @@ def prettify_xml(self):
188188 Reformat the XML in this package item to indented, human-readable
189189 form. Does nothing if this package item does not contain XML.
190190 """
191- raise NotImplementedError
191+ if self .is_content_types or self .is_xml_part or self .is_rels_item :
192+ self ._blob = etree .tostring (
193+ self .element , encoding = 'UTF-8' , standalone = True ,
194+ pretty_print = True
195+ )
192196
193197 @property
194198 def uri (self ):
Original file line number Diff line number Diff line change @@ -236,3 +236,14 @@ def it_can_calculate_its_effective_path(self):
236236 expected_path = ('root_uri\\ uri' if sys .platform .startswith ('win' )
237237 else 'root_uri/uri' )
238238 assert pkg_item .path == expected_path
239+
240+ def it_can_prettify_its_xml (self ):
241+ blob = '<foo><bar/></foo>'
242+ pkg_item = PkgItem (None , 'foo.xml' , blob )
243+ pkg_item .prettify_xml ()
244+ assert pkg_item .blob == (
245+ '<?xml version=\' 1.0\' encoding=\' UTF-8\' standalone=\' yes\' ?>\n '
246+ '<foo>\n '
247+ ' <bar/>\n '
248+ '</foo>\n '
249+ )
You can’t perform that action at this time.
0 commit comments