Skip to content

Commit 67970ac

Browse files
committed
ENH: Permit XmlSerializable.to_xml() to pass kwargs to ElementTree.tostring()
1 parent 4e7ad07 commit 67970ac

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
@@ -852,7 +852,7 @@ def _to_xml_element(self):
852852
GIFTI.append(dar._to_xml_element())
853853
return GIFTI
854854

855-
def to_xml(self, enc='utf-8', *, mode='strict') -> bytes:
855+
def to_xml(self, enc='utf-8', *, mode='strict', **kwargs) -> bytes:
856856
"""Return XML corresponding to image content"""
857857
if mode == 'strict':
858858
if any(arr.datatype not in GIFTI_DTYPES for arr in self.darrays):
@@ -882,7 +882,7 @@ def to_xml(self, enc='utf-8', *, mode='strict') -> bytes:
882882
header = b"""<?xml version="1.0" encoding="UTF-8"?>
883883
<!DOCTYPE GIFTI SYSTEM "http://www.nitrc.org/frs/download.php/115/gifti.dtd">
884884
"""
885-
return header + super().to_xml(enc)
885+
return header + super().to_xml(enc, **kwargs)
886886

887887
# Avoid the indirection of going through to_file_map
888888
def to_bytes(self, enc='utf-8', *, mode='strict'):

nibabel/xmlutils.py

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

24-
def to_xml(self, enc='utf-8'):
24+
def to_xml(self, enc='utf-8', **kwargs):
2525
"""Output should be an xml string with the given encoding.
2626
(default: utf-8)"""
2727
ele = self._to_xml_element()
28-
return '' if ele is None else tostring(ele, enc)
28+
return '' if ele is None else tostring(ele, enc, **kwargs)
2929

3030

3131
class XmlBasedHeader(FileBasedHeader, XmlSerializable):

0 commit comments

Comments
 (0)