Пример #1
0
 def write(
     self,
     fn=None,
     root=None,
     encoding='UTF-8',
     doctype=None,
     canonicalized=False,
     xml_declaration=True,
     pretty_print=True,
     with_comments=True,
 ):
     data = self.tobytes(
         root=root or self.root,
         xml_declaration=xml_declaration,
         pretty_print=pretty_print,
         encoding=encoding or self.info.encoding,
         doctype=doctype or self.info.doctype,
         canonicalized=canonicalized,
         with_comments=with_comments,
     )
     if canonicalized == True and xml_declaration == True:  # add the xml declaration
         data = ("<?xml version='1.0' encoding='%s'?>\n" % encoding).encode(encoding) + data
     File.write(self, fn=fn or self.fn, data=data)
Пример #2
0
 def write(self, fn=None, text=None, encoding='UTF-8', **args):
     try:
         data = (text or self.text or '').encode(encoding)
     except:
         data = (text or self.text or '').encode()
     File.write(self, fn=fn, data=data, **args)
Пример #3
0
 def write(self, fn=None, encoding='UTF-8', **args):
     text = self.render_styles()
     File.write(self, fn=fn, data=text.encode(encoding))
Пример #4
0
 def write(self, fn=None, text=None, encoding='UTF-8', **args):
     try:
         data = (text or self.text or '').encode(encoding)
     except:
         data = (text or self.text or '').encode()
     File.write(self, fn=fn, data=data, **args)
Пример #5
0
 def write(self, fn=None, encoding='UTF-8', **args):
     text = self.render_styles()
     File.write(self, fn=fn, data=text.encode(encoding))