python类quoteattr()的实例源码

datastore_types.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ToXml(self):
    return u'<gd:email address=%s />' % saxutils.quoteattr(self)
datastore_types.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def ToXml(self):
    return (u'<gd:im protocol=%s address=%s />' %
            (saxutils.quoteattr(self.protocol),
             saxutils.quoteattr(self.address)))
datastore.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _PropertiesToXml(self, properties):
    """ Returns a list of the XML representations of each of the given
    properties. Ignores properties that don't exist in this entity.

    Arg:
      properties: string or list of strings

    Returns:
      list of strings
    """
    xml_properties = []

    for propname in properties:
      if not self.has_key(propname):
        continue

      propname_xml = saxutils.quoteattr(propname)

      values = self[propname]
      if isinstance(values, list) and not values:



        continue
      if not isinstance(values, list):
        values = [values]

      proptype = datastore_types.PropertyTypeName(values[0])
      proptype_xml = saxutils.quoteattr(proptype)
      escaped_values = self._XmlEscapeValues(propname)

      open_tag = u'<property name=%s type=%s>' % (propname_xml, proptype_xml)
      close_tag = u'</property>'
      xml_properties += [open_tag + val + close_tag for val in escaped_values]

    return xml_properties
xunit.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _quoteattr(self, attr):
        """Escape an XML attribute. Value can be unicode."""
        attr = xml_safe(attr)
        return saxutils.quoteattr(attr)
fontfinder.py 文件源码 项目:tichu-tournament 作者: aragos 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def getTag(self):
        "Return an XML tag representation"
        attrs = []
        for k, v in self.__dict__.items():
            if k not in ['timeModified']:
                if v:
                    attrs.append('%s=%s' % (k, quoteattr(str(v))))
        return '<font ' + ' '.join(attrs) + '/>'
simplexml_connector.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def write_dict(self, dictionary):
    """Write one record for the specified entity."""
    if self.xml_style == self.ELEMENT_CENTRIC:
      self.output_stream.write('%s<%s>\n' % (self.indent, self.entity_node))
      self.write_iterable_as_elements(dictionary)
      self.output_stream.write('%s</%s>\n' % (self.indent, self.entity_node))
    else:

      self.output_stream.write('%s<%s ' % (self.indent, self.entity_node))
      for (name, value) in dictionary.iteritems():
        self.output_stream.write('%s=%s ' % (name, saxutils.quoteattr(value)))
      self.output_stream.write('/>\n')
datastore_types.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def ToXml(self):
    return u'<category term="%s" label=%s />' % (Category.TERM,
                                                 saxutils.quoteattr(self))
datastore_types.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def ToXml(self):
    return u'<link href=%s />' % saxutils.quoteattr(self)
datastore_types.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def ToXml(self):
    return u'<gd:email address=%s />' % saxutils.quoteattr(self)
datastore_types.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def ToXml(self):
    return (u'<gd:im protocol=%s address=%s />' %
            (saxutils.quoteattr(self.protocol),
             saxutils.quoteattr(self.address)))
datastore.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _PropertiesToXml(self, properties):
    """ Returns a list of the XML representations of each of the given
    properties. Ignores properties that don't exist in this entity.

    Arg:
      properties: string or list of strings

    Returns:
      list of strings
    """
    xml_properties = []

    for propname in properties:
      if not self.has_key(propname):
        continue

      propname_xml = saxutils.quoteattr(propname)

      values = self[propname]
      if isinstance(values, list) and not values:



        continue
      if not isinstance(values, list):
        values = [values]

      proptype = datastore_types.PropertyTypeName(values[0])
      proptype_xml = saxutils.quoteattr(proptype)
      escaped_values = self._XmlEscapeValues(propname)

      open_tag = u'<property name=%s type=%s>' % (propname_xml, proptype_xml)
      close_tag = u'</property>'
      xml_properties += [open_tag + val + close_tag for val in escaped_values]

    return xml_properties
xbmcaddon.py 文件源码 项目:xbmctopython 作者: pybquillast 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _parseXml(self, settingXmlFile):
        try:
            root = ET.parse(settingXmlFile).getroot()
        except:  # ParseError
            from xml.sax.saxutils import quoteattr
            with open(settingXmlFile, 'r') as f:
                content = f.read()
                content = re.sub(r'(?<==)(["\'])(.*?)\1', lambda x: quoteattr(x.group(2)), content)
            root = ET.fromstring(content)
        return root
beatbox.py 文件源码 项目:integrations-inbox 作者: astronomerio 项目源码 文件源码 阅读 48 收藏 0 点赞 0 评论 0
def startElementNS(self, name, qname, attrs):
        self._write(unicode('<' + self.makeName(name)))

        for pair in self._undeclared_ns_maps:
            self._write(unicode(' xmlns:%s="%s"' % pair))
        self._undeclared_ns_maps = []

        for (name, value) in attrs.items():
            self._write(unicode(' %s=%s' % (self.makeName(name), quoteattr(value))))
        self._write(unicode('>'))

# general purpose xml writer, does a bunch of useful stuff above & beyond XmlGenerator
beatbox.py 文件源码 项目:integrations-inbox 作者: astronomerio 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def startElementNS(self, name, qname, attrs):
        self._write(unicode('<' + self.makeName(name)))

        for pair in self._undeclared_ns_maps:
            self._write(unicode(' xmlns:%s="%s"' % pair))
        self._undeclared_ns_maps = []

        for (name, value) in attrs.items():
            self._write(unicode(' %s=%s' % (self.makeName(name), quoteattr(value))))
        self._write(unicode('>'))

# general purpose xml writer, does a bunch of useful stuff above & beyond XmlGenerator
simplexml_connector.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def write_dict(self, dictionary):
    """Write one record for the specified entity."""
    if self.xml_style == self.ELEMENT_CENTRIC:
      self.output_stream.write('%s<%s>\n' % (self.indent, self.entity_node))
      self.write_iterable_as_elements(dictionary)
      self.output_stream.write('%s</%s>\n' % (self.indent, self.entity_node))
    else:

      self.output_stream.write('%s<%s ' % (self.indent, self.entity_node))
      for (name, value) in dictionary.iteritems():
        self.output_stream.write('%s=%s ' % (name, saxutils.quoteattr(value)))
      self.output_stream.write('/>\n')
datastore_types.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def ToXml(self):
    return u'<category term="%s" label=%s />' % (Category.TERM,
                                                 saxutils.quoteattr(self))


问题


面经


文章

微信
公众号

扫码关注公众号