Skip to content

Commit 0c3eea0

Browse files
committed
ENH: Permit XmlSerializable.to_xml() to pass kwargs to ElementTree.tostring()
1 parent 0c8448e commit 0c3eea0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nibabel/gifti/gifti.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,12 +834,12 @@ def _to_xml_element(self):
834834
GIFTI.append(dar._to_xml_element())
835835
return GIFTI
836836

837-
def to_xml(self, enc='utf-8') -> bytes:
837+
def to_xml(self, enc='utf-8', **kwargs) -> bytes:
838838
"""Return XML corresponding to image content"""
839839
header = b"""<?xml version="1.0" encoding="UTF-8"?>
840840
<!DOCTYPE GIFTI SYSTEM "http://www.nitrc.org/frs/download.php/115/gifti.dtd">
841841
"""
842-
return header + super().to_xml(enc)
842+
return header + super().to_xml(enc, **kwargs)
843843

844844
# Avoid the indirection of going through to_file_map
845845
def to_bytes(self, enc='utf-8'):

nibabel/xmlutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def _to_xml_element(self):
2424
"""Output should be a xml.etree.ElementTree.Element"""
2525
raise NotImplementedError()
2626

27-
def to_xml(self, enc='utf-8'):
27+
def to_xml(self, enc='utf-8', **kwargs):
2828
"""Output should be an xml string with the given encoding.
2929
(default: utf-8)"""
3030
ele = self._to_xml_element()
31-
return '' if ele is None else tostring(ele, enc)
31+
return '' if ele is None else tostring(ele, enc, **kwargs)
3232

3333

3434
class XmlBasedHeader(FileBasedHeader, XmlSerializable):

0 commit comments

Comments
 (0)