本文整理汇总了Python中lxml.html.builder.HEAD.append方法的典型用法代码示例。如果您正苦于以下问题:Python HEAD.append方法的具体用法?Python HEAD.append怎么用?Python HEAD.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.html.builder.HEAD
的用法示例。
在下文中一共展示了HEAD.append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate
# 需要导入模块: from lxml.html.builder import HEAD [as 别名]
# 或者: from lxml.html.builder.HEAD import append [as 别名]
def _generate(self, title, masthead, datefmt, feeds, extra_css=None, style=None):
self.IS_HTML = False
if isinstance(datefmt, unicode):
datefmt = datefmt.encode(preferred_encoding)
date = "%s, %s %s, %s" % (strftime("%A"), strftime("%B"), strftime("%d").lstrip("0"), strftime("%Y"))
masthead_p = etree.Element("p")
masthead_p.set("style", "text-align:center")
masthead_img = etree.Element("img")
masthead_img.set("src", masthead)
masthead_img.set("alt", "masthead")
masthead_p.append(masthead_img)
head = HEAD(TITLE(title))
if style:
head.append(STYLE(style, type="text/css"))
if extra_css:
head.append(STYLE(extra_css, type="text/css"))
toc = TABLE(CLASS("toc"), width="100%", border="0", cellpadding="3px")
for i, feed in enumerate(feeds):
if feed:
tr = TR()
tr.append(TD(CLASS("calibre_rescale_120"), A(feed.title, href="feed_%d/index.html" % i)))
tr.append(TD("%s" % len(feed.articles), style="text-align:right"))
toc.append(tr)
div = DIV(masthead_p, H3(CLASS("publish_date"), date), DIV(CLASS("divider")), toc)
self.root = HTML(head, BODY(div))
if self.html_lang:
self.root.set("lang", self.html_lang)
示例2: _generate
# 需要导入模块: from lxml.html.builder import HEAD [as 别名]
# 或者: from lxml.html.builder.HEAD import append [as 别名]
def _generate(self, title, masthead, datefmt, feeds, extra_css=None, style=None):
self.IS_HTML = False
date = '%s, %s %s, %s' % (strftime('%A'), strftime('%B'), strftime('%d').lstrip('0'), strftime('%Y'))
masthead_p = etree.Element("p")
masthead_p.set("style","text-align:center")
masthead_img = etree.Element("img")
masthead_img.set("src",masthead)
masthead_img.set("alt","masthead")
masthead_p.append(masthead_img)
head = HEAD(TITLE(title))
if style:
head.append(STYLE(style, type='text/css'))
if extra_css:
head.append(STYLE(extra_css, type='text/css'))
toc = TABLE(CLASS('toc'),width="100%",border="0",cellpadding="3px")
for i, feed in enumerate(feeds):
if feed:
tr = TR()
tr.append(TD(CLASS('calibre_rescale_120'), A(feed.title, href='feed_%d/index.html'%i)))
tr.append(TD('%s' % len(feed.articles), style="text-align:right"))
toc.append(tr)
div = DIV(
masthead_p,
H3(CLASS('publish_date'),date),
DIV(CLASS('divider')),
toc)
self.root = HTML(head, BODY(div))
if self.html_lang:
self.root.set('lang', self.html_lang)
示例3: _generate
# 需要导入模块: from lxml.html.builder import HEAD [as 别名]
# 或者: from lxml.html.builder.HEAD import append [as 别名]
def _generate(self, bottom, feed, art, number_of_articles_in_feed,
two_levels, url, __appname__, prefix='', center=True,
extra_css=None, style=None):
head = HEAD(TITLE('navbar'))
if style:
head.append(STYLE(style, type='text/css'))
if extra_css:
head.append(STYLE(extra_css, type='text/css'))
navbar = DIV()
navbar_t = TABLE(CLASS('touchscreen_navbar'))
navbar_tr = TR()
# | Previous
if art > 0:
link = A(CLASS('article_link'),_('Previous'),href='%s../article_%d/index.html'%(prefix, art-1))
navbar_tr.append(TD(CLASS('article_prev'),link))
else:
navbar_tr.append(TD(CLASS('article_prev'),''))
# | Articles | Sections |
link = A(CLASS('articles_link'),_('Articles'), href='%s../index.html#article_%d'%(prefix, art))
navbar_tr.append(TD(CLASS('article_articles_list'),link))
link = A(CLASS('sections_link'),_('Sections'), href='%s../../index.html#feed_%d'%(prefix, feed))
navbar_tr.append(TD(CLASS('article_sections_list'),link))
# | Next
next = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
else 'article_%d'%(art+1)
up = '../..' if art == number_of_articles_in_feed - 1 else '..'
link = A(CLASS('article_link'), _('Next'), href='%s%s/%s/index.html'%(prefix, up, next))
navbar_tr.append(TD(CLASS('article_next'),link))
navbar_t.append(navbar_tr)
navbar.append(navbar_t)
#print "\n%s\n" % etree.tostring(navbar, pretty_print=True)
self.root = HTML(head, BODY(navbar))