本文整理汇总了Python中lxml.html.builder.E.span方法的典型用法代码示例。如果您正苦于以下问题:Python E.span方法的具体用法?Python E.span怎么用?Python E.span使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.html.builder.E
的用法示例。
在下文中一共展示了E.span方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _gen_row
# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import span [as 别名]
def _gen_row(self, ctx, cls, inst, parent, name, from_arr=False,
array_index=None, **kwargs):
# because HtmlForm* protocols don't use the global null handler, it's
# possible for null values to reach here.
if inst is None:
return
logger.debug("Generate row for %r", cls)
mrpc_delim_elt = ''
if self.mrpc_delim_text is not None:
mrpc_delim_elt = E.span(self.mrpc_delim_text,
**{'class': 'mrpc-delimiter'})
mrpc_delim_elt.tail = ' '
with parent.element('tr'):
for k, v in self.sort_fields(cls):
cls_attr = self.get_cls_attrs(v)
if cls_attr.exc:
logger.debug("\tExclude table cell %r type %r for %r",
k, v, cls)
continue
try:
sub_value = getattr(inst, k, None)
except: # e.g. SQLAlchemy could throw NoSuchColumnError
sub_value = None
sub_name = cls_attr.sub_name
if sub_name is None:
sub_name = k
if self.hier_delim is not None:
if array_index is None:
sub_name = "%s%s%s" % (name, self.hier_delim, sub_name)
else:
sub_name = "%s[%d]%s%s" % (name, array_index,
self.hier_delim, sub_name)
logger.debug("\tGenerate table cell %r type %r for %r",
sub_name, v, cls)
td_attrs = {}
self.add_field_attrs(td_attrs, cls_attr.sub_name or k, v)
if cls_attr.hidden:
self.add_style(td_attrs, 'display:None')
with parent.element('td', td_attrs):
ret = self.to_parent(ctx, v, sub_value, parent, sub_name,
from_arr=from_arr, array_index=array_index, **kwargs)
if isgenerator(ret):
try:
while True:
sv2 = (yield)
ret.send(sv2)
except Break as b:
try:
ret.throw(b)
except StopIteration:
pass
m = cls.Attributes.methods
if m is not None and len(m) > 0:
td_attrs = {'class': 'mrpc-cell'}
with parent.element('td', td_attrs):
first = True
for mn, md in self._methods(ctx, cls, inst):
if first:
first = False
elif mrpc_delim_elt is not None:
parent.write(" ")
parent.write(mrpc_delim_elt)
pd = {}
for k, v in self.sort_fields(cls):
if getattr(v.Attributes, 'primary_key', None):
r = self.to_unicode(v, getattr(inst, k, None))
if r is not None:
pd[k] = r
params = urlencode(pd)
mdid2key = ctx.app.interface.method_descriptor_id_to_key
href = mdid2key[id(md)].rsplit("}", 1)[-1]
text = md.translate(ctx.locale,
md.in_message.get_type_name())
parent.write(E.a(
text,
href="%s?%s" % (href, params),
**{'class': 'mrpc-operation'}
))
logger.debug("Generate row for %r done.", cls)
#.........这里部分代码省略.........