本文整理汇总了Python中xml.sax.saxutils.quoteattr函数的典型用法代码示例。如果您正苦于以下问题:Python quoteattr函数的具体用法?Python quoteattr怎么用?Python quoteattr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quoteattr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'
示例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'
示例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'
示例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)
示例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"
示例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")
示例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>')
示例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
示例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])
示例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
示例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')
示例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)
示例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'
示例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)
示例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)