• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python saxutils.quoteattr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xml.sax.saxutils.quoteattr函数的典型用法代码示例。如果您正苦于以下问题:Python quoteattr函数的具体用法?Python quoteattr怎么用?Python quoteattr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了quoteattr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: export_orderpoints

    def export_orderpoints(self):
        '''
        Defining order points for frePPLe, based on the stock.warehouse.orderpoint
        model.

        Mapping:
        stock.warehouse.orderpoint.product.name ' @ ' stock.warehouse.orderpoint.location_id.name -> buffer.name
        stock.warehouse.orderpoint.location_id.name -> buffer.location
        stock.warehouse.orderpoint.product.name -> buffer.item
        convert stock.warehouse.orderpoint.product_min_qty -> buffer.mininventory
        convert stock.warehouse.orderpoint.product_max_qty -> buffer.maxinventory
        convert stock.warehouse.orderpoint.qty_multiple -> buffer->size_multiple
        '''
        m = self.req.session.model('stock.warehouse.orderpoint')
        ids = m.search([], context=self.req.session.context)
        fields = ['warehouse_id', 'product_id', 'product_min_qty', 'product_max_qty', 'product_uom', 'qty_multiple']
        if ids:
            yield '<!-- order points -->\n'
            yield '<buffers>\n'
            for i in m.read(ids, fields, self.req.session.context):
                item = self.product_product.get(i['product_id'] and i['product_id'][0] or 0, None)
                if not item:
                    continue
                uom_factor = self.convert_qty_uom(1.0, i['product_uom'][0], i['product_id'][0])
                name = u'%s @ %s' % (item['name'], i['warehouse_id'][1])
                yield '<buffer name=%s><item name=%s/><location name=%s/>\n' \
                  '%s%s%s<booleanproperty name="ip_flag" value="true"/>\n' \
                  '<stringproperty name="roq_type" value="quantity"/>\n<stringproperty name="ss_type" value="quantity"/>\n' \
                  '</buffer>\n' % (
                        quoteattr(name), quoteattr(item['name']), quoteattr(i['warehouse_id'][1]),
                        '<doubleproperty name="ss_min_qty" value="%s"/>\n' % (i['product_min_qty'] * uom_factor) if i['product_min_qty'] else '',
                        '<doubleproperty name="roq_min_qty" value="%s"/>\n' % ((i['product_max_qty']-i['product_min_qty']) * uom_factor) if (i['product_max_qty']-i['product_min_qty']) else '',
                        '<doubleproperty name="roq_multiple_qty" value="%s"/>\n' % (i['qty_multiple'] * uom_factor) if i['qty_multiple'] else '',
                    )
            yield '</buffers>\n'
开发者ID:frePPLe,项目名称:frePPLe,代码行数:35,代码来源:outbound.py


示例2: export_workcenters

    def export_workcenters(self):
        '''
Send the workcenter list to frePPLe, based one the mrp.workcenter model.

We assume the workcenter name is unique. Odoo does NOT guarantuee that.

Mapping:
mrp.workcenter.name -> resource.name
mrp.workcenter.costs_hour -> resource.cost
mrp.workcenter.capacity_per_cycle / mrp.workcenter.time_cycle -> resource.maximum
'''
        self.map_workcenters = {}
        m = self.req.session.model('mrp.workcenter')
        ids = m.search([], context=self.req.session.context)
        fields = ['name', 'costs_hour', 'capacity_per_cycle', 'time_cycle']
        if ids:
            yield '<!-- workcenters -->\n'
            yield '<resources>\n'
            for i in m.read(ids, fields, self.req.session.context):
                name = i['name']
                self.map_workcenters[i['id']] = name
                yield '<resource name=%s maximum="%s" cost="%f"><location name=%s/></resource>\n' % (
                    quoteattr(name), i['capacity_per_cycle'] / (i['time_cycle'] or 1),
                    i['costs_hour'], quoteattr(self.mfg_location)
                )
            yield '</resources>\n'
开发者ID:DwBu,项目名称:frePPLe,代码行数:26,代码来源:outbound.py


示例3: export_onhand

    def export_onhand(self):
        '''
Extracting all on hand inventories to frePPLe.

We're bypassing the ORM for performance reasons.

Mapping:
stock.report.prodlots.product_id.name @ stock.report.prodlots.location_id.name -> buffer.name
stock.report.prodlots.product_id.name -> buffer.item
stock.report.prodlots.location_id.name -> buffer.location
sum(stock.report.prodlots.qty) -> buffer.onhand
'''
        yield '<!-- inventory -->\n'
        yield '<buffers>\n'
        cr = RegistryManager.get(self.database).cursor()
        try:
            cr.execute('SELECT product_id, location_id, sum(qty) '
                       'FROM stock_quant '
                       'WHERE qty > 0 '
                       'GROUP BY product_id, location_id')
            for i in cr.fetchall():
                item = self.product_product.get(i[0], None)
                location = self.map_locations.get(i[1], None)
                if location and item:
                    yield '<buffer name=%s onhand="%f"><item name=%s/><location name=%s/></buffer>\n' % (
                        quoteattr(u'%s @ %s' % (item['name'], location)),
                        i[2], quoteattr(item['name']), quoteattr(location)
                    )
        finally:
            cr.close()
        yield '</buffers>\n'
开发者ID:DwBu,项目名称:frePPLe,代码行数:31,代码来源:outbound.py


示例4: plugin_to_index

def plugin_to_index(plugin):
    title = '<h3><img src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/32/Apps-preferences-plugin-icon.png"><a href=%s title="Plugin forum thread">%s</a></h3>' % (  # noqa
        quoteattr(plugin['thread_url']), escape(plugin['name']))
    released = datetime(*tuple(map(int, re.split(r'\D', plugin['last_modified'])))[:6]).strftime('%e %b, %Y').lstrip()
    details = [
        'Version: <b>%s</b>' % escape('.'.join(map(str, plugin['version']))),
        'Released: <b>%s</b>' % escape(released),
        'Author: %s' % escape(plugin['author']),
        'History: %s' % escape('Yes' if plugin['history'] else 'No'),
        'calibre: %s' % escape('.'.join(map(str, plugin['minimum_calibre_version']))),
        'Platforms: %s' % escape(', '.join(sorted(plugin['supported_platforms']) or ['all'])),
    ]
    if plugin['uninstall']:
        details.append('Uninstall: %s' % escape(', '.join(plugin['uninstall'])))
    if plugin['donate']:
        details.append('<a href=%s title="Donate">Donate</a>' % quoteattr(plugin['donate']))
    block = []
    for li in details:
        if li.startswith('calibre:'):
            block.append('<br>')
        block.append('<li>%s</li>' % li)
    block = '<ul>%s</ul>' % ('\n'.join(block))
    zipfile = '<div class="end"><a href=%s title="Download plugin" download=%s>Download plugin \u2193</a></div>' % (
        quoteattr(plugin['file']), quoteattr(plugin['name'] + '.zip'))
    desc = plugin['description'] or ''
    if desc:
        desc = '<p>%s</p>' % desc
    return '%s\n%s\n%s\n%s\n\n' % (title, desc, block, zipfile)
开发者ID:BatteringRam,项目名称:calibre,代码行数:28,代码来源:plugins_mirror.py


示例5: export_workcenters

    def export_workcenters(self):
        """
    Send the workcenter list to frePPLe, based one the mrp.workcenter model.

    We assume the workcenter name is unique. Odoo does NOT guarantuee that.

    Mapping:
    mrp.workcenter.name -> resource.name
    mrp.workcenter.costs_hour -> resource.cost
    mrp.workcenter.capacity_per_cycle / mrp.workcenter.time_cycle -> resource.maximum
    """
        self.map_workcenters = {}
        m = self.req.session.model("mrp.workcenter")
        ids = m.search([], context=self.req.session.context)
        fields = ["name", "costs_hour", "capacity_per_cycle", "time_cycle"]
        if ids:
            yield "<!-- workcenters -->\n"
            yield "<resources>\n"
            for i in m.read(ids, fields, self.req.session.context):
                name = i["name"]
                self.map_workcenters[i["id"]] = name
                yield '<resource name=%s maximum="%s" cost="%f"><location name=%s/></resource>\n' % (
                    quoteattr(name),
                    i["capacity_per_cycle"] / (i["time_cycle"] or 1),
                    i["costs_hour"],
                    quoteattr(self.mfg_location),
                )
            yield "</resources>\n"
开发者ID:dhl,项目名称:frePPLe,代码行数:28,代码来源:outbound.py


示例6: CreateChangeSet

	def CreateChangeSet(self, tags):
		#Create a changeset
		createChangeset = u"<?xml version='1.0' encoding='UTF-8'?>\n" +\
		u"<osm version='0.6' generator='py'>\n" +\
		u"  <changeset>\n"
		for k in tags:
			createChangeset += u'<tag k={0} v={1}/>\n'.format(saxutils.quoteattr(k), saxutils.quoteattr(tags[k]))
		createChangeset += u"  </changeset>\n" +\
		u"</osm>\n"

		if self.verbose >= 2:
			print (createChangeset)

		if self.exe:
			
			r = requests.put(self.baseurl+"/0.6/changeset/create", data=createChangeset.encode('utf-8'), 
				auth=HTTPBasicAuth(self.user, self.passw),
				headers=self.xmlHeaders)

			if r.status_code != 200: 
				print (r.content)
				return (0,"Error creating changeset")
			if self.verbose >= 1: print (r.content)
			if len(r.content) == 0:
				return (0,"Error creating changeset")
			cid = int(r.content)
		else:
			cid = 1001
		return (cid, "Done")
开发者ID:TimSC,项目名称:fosm-fix-missing-nodes,代码行数:29,代码来源:osmmod.py


示例7: __add

    def __add(self, lst, fields):
        lst.append(u'<doc>')
        for field, value in fields.items():
            # Handle multi-valued fields if values
            # is passed in as a list/tuple
            if not isinstance(value, (list, tuple)): 
                values = [value]
            else: 
                values = value 

            for val in values: 
                # Do some basic data conversion
                if isinstance(val, datetime.datetime): 
                    val = utc_to_string(val)
                elif isinstance(val, bool): 
                    val = val and 'true' or 'false'

                try:
                    lst.append('<field name=%s>%s</field>' % (
                        (quoteattr(field), 
                        escape(unicode(val)))))
                except UnicodeDecodeError:
                    lst.append('<field name=%s> </field>' % (
                        (quoteattr(field))))
        lst.append('</doc>')
开发者ID:Dav1dde,项目名称:emfas,代码行数:25,代码来源:solr.py


示例8: getVars

 def getVars(self):
     vars=wcomponents.WTemplated.getVars(self)
     vars["code"]=quoteattr(str(self._track.getCode()))
     vars["title"]=quoteattr(str(self._track.getTitle()))
     vars["description"]=self.htmlText(self._track.getDescription())
     vars["postURL"]=quoteattr(str(urlHandlers.UHTrackPerformDataModification.getURL(self._track)))
     return vars
开发者ID:belokop,项目名称:indico_bare,代码行数:7,代码来源:tracks.py


示例9: attributes

def attributes(data):
    if isinstance(data, basestring):
        return data
    elif isinstance(data, dict):
        return ' '.join(['{}={}'.format(k, quoteattr(v)) for k,v in data.items()])
    else:
        return ' '.join(['{}={}'.format(k, quoteattr(v)) for k,v in data])
开发者ID:UFOstart,项目名称:UFOStart,代码行数:7,代码来源:html.py


示例10: getVars

 def getVars( self ):
     vars = wcomponents.WTemplated.getVars(self)
     modPay=self._conf.getModPay()
     vars["setStatusURL"]=urlHandlers.UHConfModifEPaymentChangeStatus.getURL(self._conf)
     vars["enablePic"]=quoteattr(str(Configuration.Config.getInstance().getSystemIconURL( "enabledSection" )))
     vars["disablePic"]=quoteattr(str(Configuration.Config.getInstance().getSystemIconURL( "disabledSection" )))
     if modPay.isActivated():
         vars["changeTo"] = "False"
         vars["status"] = _("ENABLED")
         vars["changeStatus"] = _("DISABLE")
         vars["disabled"] = ""
         vars["detailPayment"] = self._conf.getModPay().getPaymentDetails()
         vars["conditionsPayment"] = self._conf.getModPay().getPaymentConditions()
         vars["specificConditionsPayment"] = self._conf.getModPay().getPaymentSpecificConditions()
         vars["successMsgPayment"] = self._conf.getModPay().getPaymentSuccessMsg()
         vars["receiptMsgPayment"] = self._conf.getModPay().getPaymentReceiptMsg()
         vars["conditionsEnabled"] = "DISABLED"
         if self._conf.getModPay().arePaymentConditionsEnabled():
             vars["conditionsEnabled"] = "ENABLED"
         vars["Currency"]=self._conf.getRegistrationForm().getCurrency() or _("not selected")
     else:
         vars["changeTo"] = "True"
         vars["status"] = _("DISABLED")
         vars["changeStatus"] = _("ENABLE")
         vars["disabled"] = "disabled"
         vars["detailPayment"] = ""
         vars["conditionsPayment"] = ""
         vars["conditionsEnabled"] = "DISABLED"
         vars["specificConditionsPayment"] = ""
         vars["successMsgPayment"] = ""
         vars["receiptMsgPayment"] = ""
         vars["Currency"] = ""
     vars["dataModificationURL"]=urlHandlers.UHConfModifEPaymentdetailPaymentModification.getURL(self._conf)
     vars["sections"] = self._getSectionsHTML()
     return vars
开发者ID:bubbas,项目名称:indico,代码行数:35,代码来源:epayments.py


示例11: append_item

 def append_item(self, item, outfile, tabs):
     write = outfile.write
     if item.name == '---': # item is a separator
         write('    '*tabs + '<object class="separator"/>\n')
     else:
         if item.children:
             name = self.get_name(item)
             if name:
                 write('    '*tabs + '<object class="wxMenu" ' \
                       'name=%s>\n' % quoteattr(name))
             else:
                 write('    '*tabs + '<object class="wxMenu">\n')
         else:
             name = self.get_name(item)
             if name:
                 write('    '*tabs + '<object class="wxMenuItem" ' \
                       'name=%s>\n' % quoteattr(name))
             else:
                 write('    '*tabs + '<object class="wxMenuItem">\n')  
         if item.label:
             # translate & into _ as accelerator marker
             val = item.label.replace('&', '_')
             write('    '*(tabs+1) + '<label>%s</label>\n' % \
                   escape(val))
         if item.help_str:
             write('    '*(tabs+1) + '<help>%s</help>\n' % \
                   escape(item.help_str))
         if item.children:
             for c in item.children:
                 self.append_item(c, outfile, tabs+1)
         elif item.checkable == '1':
             write('    '*(tabs+1) + '<checkable>1</checkable>\n')
         elif item.radio == '1':
             write('    '*(tabs+1) + '<radio>1</radio>\n')
         write('    '*tabs + '</object>\n')
开发者ID:CrazyPython,项目名称:SPE,代码行数:35,代码来源:codegen.py


示例12: add_dict_entry_internal

    def add_dict_entry_internal(self, formatted_head_word, forms, formatted_desc):
        self.n_expanded_entries += 1
        self.index_size += len(forms)

        if self.entries_in_curr_dict_html >= self.max_entries_per_dict_html:
            self.close_dict_html()
            self.start_dict_html()

        self.entries_in_curr_dict_html += 1
                                                    
        self.curr_dict_f.write("""
        <idx:entry scriptable="yes" spell="yes">
          <idx:short>
            <idx:orth value=%s>%s
        """ % (quoteattr(forms[0]), formatted_head_word))

        if len(forms[1:]) > 0:
            self.curr_dict_f.write("""
            <idx:infl>
            """)

            for infl in forms[1:]:
                self.curr_dict_f.write("""<idx:iform value=%s exact="yes"/>\n""" % quoteattr(infl))

            self.curr_dict_f.write("""
            </idx:infl>
            """)

        self.curr_dict_f.write("""
           </idx:orth>
           %s
         </idx:short>
	</idx:entry>
        """ % formatted_desc)
开发者ID:runehol,项目名称:kindlearadict,代码行数:34,代码来源:opfgen.py


示例13: export_onhand

    def export_onhand(self):
        '''
        Extracting all on hand inventories to frePPLe.

        We're bypassing the ORM for performance reasons.

        Mapping:
        stock.report.prodlots.product_id.name @ stock.report.prodlots.location_id.name -> buffer.name
        stock.report.prodlots.product_id.name -> buffer.item
        stock.report.prodlots.location_id.name -> buffer.location
        sum(stock.report.prodlots.qty) -> buffer.onhand
        '''
        yield '<!-- inventory -->\n'
        yield '<buffers>\n'
        cr = RegistryManager.get(self.database).cursor()
        try:
            cr.execute('SELECT product_id, location_id, sum(qty) '
                       'FROM stock_quant '
                       'WHERE qty > 0 '
                       'GROUP BY product_id, location_id '
                       'ORDER BY location_id ASC')
            inventory = {}
            for i in cr.fetchall():
                item = self.product_product.get(i[0], None)
                location = self.map_locations.get(i[1], None)
                if item and location:
                    inventory[ (item['name'], location) ] = i[2] + inventory.get( (item['name'], location), 0)
            for key, val in inventory.items():
                buf = "%s @ %s" % (key[0], key[1])
                yield '<buffer name=%s onhand="%f"><item name=%s/><location name=%s/></buffer>\n' % (
                    quoteattr(buf), val, quoteattr(key[0]), quoteattr(key[1])
                    )
        finally:
            cr.close()
        yield '</buffers>\n'
开发者ID:frePPLe,项目名称:frePPLe,代码行数:35,代码来源:outbound.py


示例14: _make_ns_declarations

    def _make_ns_declarations(declarations, declared_prefixes):
        """Build namespace declarations and remove obsoleted mappings
        from `declared_prefixes`.

        :Parameters:
            - `declarations`: namespace to prefix mapping of the new
              declarations
            - `declared_prefixes`: namespace to prefix mapping of already
              declared prefixes.
        :Types:
            - `declarations`: `unicode` to `unicode` dictionary
            - `declared_prefixes`: `unicode` to `unicode` dictionary

        :Return: string of namespace declarations to be used in a start tag
        :Returntype: `unicode`
        """
        result = []
        for namespace, prefix in declarations.items():
            if prefix:
                result.append(u" xmlns:{0}={1}".format(prefix, quoteattr(namespace)))
            else:
                result.append(u" xmlns={1}".format(prefix, quoteattr(namespace)))
            for d_namespace, d_prefix in declared_prefixes.items():
                if (not prefix and not d_prefix) or d_prefix == prefix:
                    if namespace != d_namespace:
                        del declared_prefixes[d_namespace]
        return u" ".join(result)
开发者ID:kenhancoder,项目名称:pyxmpp2,代码行数:27,代码来源:xmppserializer.py


示例15: ModifyRelation

	def ModifyRelation(self, cid, members, tags, rid, existingVersion):

		xml = u"<?xml version='1.0' encoding='UTF-8'?>\n"
		xml += u'<osmChange version="0.6" generator="py">\n<modify>\n<relation id="{0}" changeset="{1}" version="{2}">\n'.format(rid, cid, existingVersion)
		for mem in members:
			xml += u'<member type="{}" role={} ref="{}"/>\n'.format(mem['type'], saxutils.quoteattr(mem['role']), int(mem['ref']))
		for k in tags:
			xml += u'<tag k={0} v={1}/>\n'.format(saxutils.quoteattr(k), saxutils.quoteattr(tags[k]))
		xml += u'</relation>\n</modify>\n</osmChange>\n'
		if self.verbose >= 2: print (xml)
		newId = None
		newVersion = None

		if self.exe:
			r = requests.post(self.baseurl+"/0.6/changeset/"+str(cid)+"/upload", data=xml.encode('utf-8'), 
				auth=HTTPBasicAuth(self.user, self.passw),
				headers=self.xmlHeaders)

			if self.verbose >= 1: print (r.content)
			if r.status_code != 200: return None

			respRoot = ET.fromstring(r.content)
			for obj in respRoot:
				newId = obj.attrib['new_id']
				newVersion = obj.attrib['new_version']

		return int(newId), int(newVersion)
开发者ID:TimSC,项目名称:fosm-fix-missing-nodes,代码行数:27,代码来源:osmmod.py


示例16: getPendingNamespaces

 def getPendingNamespaces(self):
     parts = []
     if self.pendingDefault is not None:
         parts.append("xmlns=%s" % quoteattr(self.pendingDefault))
     for prefix, uri in self.pending.items():
         parts.append("xmlns:%s=%s" % (prefix, quoteattr(uri)))
     return parts
开发者ID:sbna,项目名称:balcazapy,代码行数:7,代码来源:XMLExport.py


示例17: CreateNode

	def CreateNode(self, cid, lat, lon, tags):

		xml = u"<?xml version='1.0' encoding='UTF-8'?>\n"
		xml += u'<osmChange version="0.6" generator="py">\n<create>\n<node id="-1" lat="{0}" lon="{1}" changeset="{2}">\n'.format(lat, lon, cid)
		for k in tags:
			xml += u'<tag k={0} v={1}/>\n'.format(saxutils.quoteattr(k), saxutils.quoteattr(tags[k]))
		xml += u'</node>\n</create>\n</osmChange>\n'
		if self.verbose >= 2: print (xml)
		newId = None
		newVersion = None

		if self.exe:
			r = requests.post(self.baseurl+"/0.6/changeset/"+str(cid)+"/upload", data=xml.encode('utf-8'), 
				auth=HTTPBasicAuth(self.user, self.passw),
				headers=self.xmlHeaders)

			if self.verbose >= 1: print (r.content)
			if r.status_code != 200: return None

			respRoot = ET.fromstring(r.content)
			for obj in respRoot:
				newId = obj.attrib['new_id']
				newVersion = obj.attrib['new_version']

		return int(newId), int(newVersion)
开发者ID:TimSC,项目名称:fosm-fix-missing-nodes,代码行数:25,代码来源:osmmod.py


示例18: plugin_to_index

def plugin_to_index(plugin, count):
    title = '<h3><img src="/plugin-icon.png"><a href=%s title="Plugin forum thread">%s</a></h3>' % (  # noqa
        quoteattr(plugin["thread_url"]),
        escape(plugin["name"]),
    )
    released = datetime(*tuple(map(int, re.split(r"\D", plugin["last_modified"])))[:6]).strftime("%e %b, %Y").lstrip()
    details = [
        "Version: <b>%s</b>" % escape(".".join(map(str, plugin["version"]))),
        "Released: <b>%s</b>" % escape(released),
        "Author: %s" % escape(plugin["author"]),
        "History: %s" % escape("Yes" if plugin["history"] else "No"),
        "calibre: %s" % escape(".".join(map(str, plugin["minimum_calibre_version"]))),
        "Platforms: %s" % escape(", ".join(sorted(plugin["supported_platforms"]) or ["all"])),
    ]
    if plugin["uninstall"]:
        details.append("Uninstall: %s" % escape(", ".join(plugin["uninstall"])))
    if plugin["donate"]:
        details.append('<a href=%s title="Donate">Donate</a>' % quoteattr(plugin["donate"]))
    block = []
    for li in details:
        if li.startswith("calibre:"):
            block.append("<br>")
        block.append("<li>%s</li>" % li)
    block = "<ul>%s</ul>" % ("\n".join(block))
    downloads = ('\xa0<span class="download-count">[%d total downloads]</span>' % count) if count else ""
    zipfile = '<div class="end"><a href=%s title="Download plugin" download=%s>Download plugin \u2193</a>%s</div>' % (
        quoteattr(plugin["file"]),
        quoteattr(plugin["name"] + ".zip"),
        downloads,
    )
    desc = plugin["description"] or ""
    if desc:
        desc = "<p>%s</p>" % desc
    return "%s\n%s\n%s\n%s\n\n" % (title, desc, block, zipfile)
开发者ID:sramsubbu,项目名称:calibre,代码行数:34,代码来源:plugins_mirror.py


示例19: _open_folder_entry

 def _open_folder_entry(self, folder):
     if self.current_folder is not None:
         self._close_folder_entry()
     self.current_folder = folder
     self.io.write(u'\t<outline text=%s miro:section=%s>\n' % (
         saxutils.quoteattr(folder.get_title()),
         saxutils.quoteattr(folder.section)))
开发者ID:cool-RR,项目名称:Miro,代码行数:7,代码来源:opml.py


示例20: tigerxml

def tigerxml(tree, stream, **params):
    """A single sentence as TIGER XML. The IDs should probably
    be more fancy.
    """
    compute_export_numbering(tree)
    stream.write(u"<s id=\"%d\">\n" % tree.data['sid'])
    stream.write(u"<graph root=\"%s\">\n" % tree.data['num'])
    stream.write(u"  <terminals>\n")
    for terminal in trees.terminals(tree):
        stream.write(u"    <t id=\"%d\" " % terminal.data['num'])
        for field in ['word', 'lemma', 'label', 'morph']:
            terminal.data[field] = quoteattr(terminal.data[field])
        stream.write(u"%s=%s " % ('word', terminal.data['word']))
        stream.write(u"%s=%s " % ('lemma', terminal.data['lemma']))
        stream.write(u"%s=%s " % ('pos', terminal.data['label']))
        stream.write(u"%s=%s " % ('morph', terminal.data['morph']))
        stream.write(u"/>\n")
    stream.write(u"  </terminals>\n")
    stream.write(u"  <nonterminals>\n")
    for subtree in trees.postorder(tree):
        if trees.has_children(subtree):
            stream.write(u"    <nt id=\"%d\" cat=%s>\n"
                         % (subtree.data['num'],
                            quoteattr(subtree.data['label'])))
            for child in trees.children(subtree):
                stream.write(u"      <edge label=%s idref=\"%d\" />\n"
                             % (quoteattr(child.data['edge']),
                                child.data['num']))
            stream.write(u"    </nt>\n")
    stream.write(u"  </nonterminals>\n")
    stream.write(u"</graph>\n")
    stream.write(u"</s>\n")
开发者ID:xiaoyangren,项目名称:treetools,代码行数:32,代码来源:treeoutput.py



注:本文中的xml.sax.saxutils.quoteattr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python saxutils.unescape函数代码示例发布时间:2022-05-26
下一篇:
Python saxutils.prepare_input_source函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap