File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 15
15
16
16
17
17
class XmlSerializable :
18
- """Basic interface for serializing an object to xml """
18
+ """Basic interface for serializing an object to XML """
19
19
20
- def _to_xml_element (self ):
20
+ def _to_xml_element (self ) -> Element :
21
21
"""Output should be a xml.etree.ElementTree.Element"""
22
- raise NotImplementedError ()
22
+ raise NotImplementedError
23
+
24
+ def to_xml (self , enc = 'utf-8' , ** kwargs ) -> bytes :
25
+ r"""Generate an XML bytestring with a given encoding.
23
26
24
- def to_xml (self , enc = 'utf-8' , ** kwargs ):
25
- """Output should be an xml string with the given encoding.
26
- (default: utf-8)"""
27
+ Parameters
28
+ ----------
29
+ enc : :class:`string`
30
+ Encoding to use for the generated bytestring. Default: 'utf-8'
31
+ \*\*kwargs : :class:`dict`
32
+ Additional keyword arguments to :func:`xml.etree.ElementTree.tostring`.
33
+ """
27
34
ele = self ._to_xml_element ()
28
- return '' if ele is None else tostring (ele , enc , ** kwargs )
35
+ return b '' if ele is None else tostring (ele , enc , ** kwargs )
29
36
30
37
31
38
class XmlBasedHeader (FileBasedHeader , XmlSerializable ):
You can’t perform that action at this time.
0 commit comments