本文整理汇总了Python中lxml.html.builder.E.div方法的典型用法代码示例。如果您正苦于以下问题:Python E.div方法的具体用法?Python E.div怎么用?Python E.div使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.html.builder.E
的用法示例。
在下文中一共展示了E.div方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _build_html_header
# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import div [as 别名]
def _build_html_header(self):
'''Add banner and account links'''
header = self.elements.header
index_url = self.links.get(
'index', self.handler.reverse_url('index'))
header.append(E.div(
E.a(self.meta.app_name, href=index_url, id='logo-link'),
id='logo-wrapper'
))
示例2: serialize
# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import div [as 别名]
def serialize(self, ctx, message):
"""Uses ``ctx.out_object``, ``ctx.out_header`` or ``ctx.out_error`` to
set ``ctx.out_body_doc``, ``ctx.out_header_doc`` and
``ctx.out_document`` as an ``lxml.etree._Element instance``.
Not meant to be overridden.
"""
assert message in (self.REQUEST, self.RESPONSE)
self.event_manager.fire_event('before_serialize', ctx)
if ctx.out_stream is None:
ctx.out_stream = StringIO()
if ctx.out_error is not None:
# All errors at this point must be Fault subclasses.
inst = ctx.out_error
cls = inst.__class__
name = cls.get_type_name()
ctx.out_document = E.div()
from lxml import etree
with etree.xmlfile(ctx.out_stream) as xf:
retval = HtmlBase.HtmlMicroFormat() \
.to_parent(ctx, cls, inst, xf, name)
else:
assert message is self.RESPONSE
result_message_class = ctx.descriptor.out_message
name = result_message_class.get_type_name()
if ctx.descriptor.body_style == BODY_STYLE_WRAPPED:
if self.ignore_wrappers:
ctx.out_object = ctx.out_object[0]
result_message = ctx.out_object
while result_message_class.Attributes._wrapper:
result_message_class = next(iter(
result_message_class._type_info.values()))
else:
result_message = result_message_class()
for i, attr_name in enumerate(
result_message_class._type_info.keys()):
setattr(result_message, attr_name, ctx.out_object[i])
else:
result_message = ctx.out_object
retval = self.incgen(ctx, result_message_class, result_message, name)
self.event_manager.fire_event('after_serialize', ctx)
return retval
示例3: add_field
# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import div [as 别名]
def add_field(self, field):
translate = self._handler.locale.translate
wrapper = E.div()
if field.label:
wrapper.append(E.label(translate(field.label.text), FOR(field.id)))
wrapper.append(lxml.html.fromstring(field()))
if field.errors:
error_wrapper = E.ul()
wrapper.append(error_wrapper)
for error in field.errors:
error_wrapper.append(E.li(E.strong(str(error))))
self._element.append(wrapper)
示例4: __init__
# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import div [as 别名]
def __init__(self, **kwargs):
super().__init__(**kwargs)
footer = E.footer(role='contentinfo', id='layout-footer')
content = E.main(role='main', id='layout-content')
header = E.header(role='banner', id='layout-header')
layout = E.div(header, content, footer, id='layout-wrapper')
body = E.body(layout)
head = E.head(prefix='og: http://ogp.me/ns#')
html = E.html(head, body, dir='rtl' if self.locale.rtl else 'ltr')
self.elements = Elements(html=html, head=head, body=body,
layout=layout, header=header, content=content, footer=footer)
self.meta = HTMLMeta()
self.links = HTMLLinks()
self.stylesheets = []
self.scripts = []
self.meta.app_name = self.handler.application.settings[
'application_name']
示例5: index
# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import div [as 别名]
def index(self):
return E.div(
E.p(E.a("Cards", href="/get_all_card")),
E.p(E.a("Sip Buddies", href="/get_all_sip_buddy")),
E.p(E.a("Extensions", href="/get_all_extension")),
)