code: def __init__(
      self,
      fileOrPath,
      indentwhite=INDENT,
      idlefunc=None,
      encoding="utf_8",
      newlinestr="\n",
  ):
      if encoding.lower().replace("-", "").replace("_", "") != "utf8":
          raise Exception("Only UTF-8 encoding is supported.")
      if fileOrPath == "-":
          fileOrPath = sys.stdout
      if not hasattr(fileOrPath, "write"):
          self.filename = fileOrPath
          self.file = open(fileOrPath, "wb")
          self._closeStream = True
      else:
          self.filename = None
          # assume writable file object
          self.file = fileOrPath
          self._closeStream = False
  
      # Figure out if writer expects bytes or unicodes
      try:
          # The bytes check should be first.  See:
          # https://github.com/fonttools/fonttools/pull/233
          self.file.write(b"")
          self.totype = tobytes
      except TypeError:
          # This better not fail.
          self.file.write("")
          self.totype = tostr
      self.indentwhite = self.totype(indentwhite)
      if newlinestr is None:
          self.newlinestr = self.totype(os.linesep)
      else:
          self.newlinestr = self.totype(newlinestr)
      self.indentlevel = 0
      self.stack = []
      self.needindent = 1
      self.idlefunc = idlefunc
      self.idlecounter = 0
      self._writeraw('<?xml version="1.0" encoding="UTF-8"?>')
      self.newline()
  
imports: from fontTools.misc.textTools import byteord, strjoin, tobytes, tostr
  import sys
  import os
  import string
label_desc: Use image node_id 1 to create a new XMLWriter object from inherited base classes: object with example: obj = XMLWriter(fileOrPath, indentwhite, idlefunc, encoding, newlinestr)