def WriteXML(self, file):
    """ Dump non-empty contents to the output file, in XML format. """
    if not self.loc:
      return
    out = SITEURL_XML_PREFIX

    for attribute in self.__slots__:
      value = getattr(self, attribute)
      if value:
        if type(value) == types.UnicodeType:
          value = encoder.NarrowText(value, None)
        elif type(value) != types.StringType:
          value = str(value)
        value = xml.sax.saxutils.escape(value)
        out = out + ('  <%s>%s</%s>\n' % (attribute, value, attribute))

    out = out + SITEURL_XML_SUFFIX
    file.write(out)
  #end def WriteXML
#end class URL
dataset/ETHPy150Open benoitc/gunicorn/docs/sitemap_gen.py/URL.WriteXML/original