当前位置: 首页>>代码示例>>Python>>正文


Python DIV.text方法代码示例

本文整理汇总了Python中lxml.html.builder.DIV.text方法的典型用法代码示例。如果您正苦于以下问题:Python DIV.text方法的具体用法?Python DIV.text怎么用?Python DIV.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lxml.html.builder.DIV的用法示例。


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

示例1: _generate

# 需要导入模块: from lxml.html.builder import DIV [as 别名]
# 或者: from lxml.html.builder.DIV import text [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"))

        if prefix and not prefix.endswith("/"):
            prefix += "/"
        align = "center" if center else "left"

        navbar = DIV(CLASS("calibre_navbar", "calibre_rescale_70", style="text-align:" + align))
        if bottom:
            if not url.startswith("file://"):
                navbar.append(HR())
                text = "This article was downloaded by "
                p = PT(
                    text,
                    STRONG(__appname__),
                    A(url, href=url, rel="calibre-downloaded-from"),
                    style="text-align:left; max-width: 100%; overflow: hidden;",
                )
                p[0].tail = " from "
                navbar.append(p)
                navbar.append(BR())
            navbar.append(BR())
        else:
            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 ".."
            href = "%s%s/%s/index.html" % (prefix, up, next)
            navbar.text = "| "
            navbar.append(A(_("Next"), href=href))
        href = "%s../index.html#article_%d" % (prefix, art)
        navbar.iterchildren(reversed=True).next().tail = " | "
        navbar.append(A(_("Section Menu"), href=href))
        href = "%s../../index.html#feed_%d" % (prefix, feed)
        navbar.iterchildren(reversed=True).next().tail = " | "
        navbar.append(A(_("Main Menu"), href=href))
        if art > 0 and not bottom:
            href = "%s../article_%d/index.html" % (prefix, art - 1)
            navbar.iterchildren(reversed=True).next().tail = " | "
            navbar.append(A(_("Previous"), href=href))
        navbar.iterchildren(reversed=True).next().tail = " | "
        if not bottom:
            navbar.append(HR())

        self.root = HTML(head, BODY(navbar))
开发者ID:JapaChin,项目名称:calibre,代码行数:62,代码来源:templates.py

示例2: get_navbar

# 需要导入模块: from lxml.html.builder import DIV [as 别名]
# 或者: from lxml.html.builder.DIV import text [as 别名]
    def get_navbar(self, f, feeds, top=True):
        if len(feeds) < 2:
            return DIV()
        navbar = DIV('| ', CLASS('calibre_navbar', 'calibre_rescale_70',
            style='text-align:center'))
        if not top:
            hr = HR()
            navbar.append(hr)
            navbar.text = None
            hr.tail = '| '

        if f+1 < len(feeds):
            link = A(_('Next section'), href='../feed_%d/index.html'%(f+1))
            link.tail = ' | '
            navbar.append(link)
        link = A(_('Main menu'), href="../index.html")
        link.tail = ' | '
        navbar.append(link)
        if f > 0:
            link = A(_('Previous section'), href='../feed_%d/index.html'%(f-1))
            link.tail = ' |'
            navbar.append(link)
        if top:
            navbar.append(HR())
        return navbar
开发者ID:JimmXinu,项目名称:calibre,代码行数:27,代码来源:templates.py

示例3: _generate

# 需要导入模块: from lxml.html.builder import DIV [as 别名]
# 或者: from lxml.html.builder.DIV import text [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'))

        if prefix and not prefix.endswith('/'):
            prefix += '/'
        align = 'center' if center else 'left'

        navbar = DIV(CLASS('calibre_navbar', 'calibre_rescale_70',
            style='text-align:'+align))
        if bottom:
            if not url.startswith('file://'):
                navbar.append(HR())
                text = 'This article was downloaded by '
                p = PT(text, STRONG(__appname__), A(url, href=url, rel='calibre-downloaded-from'),
                        style='text-align:left; max-width: 100%; overflow: hidden;')
                p[0].tail = ' from '
                navbar.append(p)
                navbar.append(BR())
            navbar.append(BR())
        else:
            next_art = '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 '..'
            href = '%s%s/%s/index.html'%(prefix, up, next_art)
            navbar.text = '| '
            navbar.append(A(_('Next'), href=href))
        href = '%s../index.html#article_%d'%(prefix, art)
        next(navbar.iterchildren(reversed=True)).tail = ' | '
        navbar.append(A(_('Section menu'), href=href))
        href = '%s../../index.html#feed_%d'%(prefix, feed)
        next(navbar.iterchildren(reversed=True)).tail = ' | '
        navbar.append(A(_('Main menu'), href=href))
        if art > 0 and not bottom:
            href = '%s../article_%d/index.html'%(prefix, art-1)
            next(navbar.iterchildren(reversed=True)).tail = ' | '
            navbar.append(A(_('Previous'), href=href))
        next(navbar.iterchildren(reversed=True)).tail = ' | '
        if not bottom:
            navbar.append(HR())

        self.root = HTML(head, BODY(navbar))
开发者ID:JimmXinu,项目名称:calibre,代码行数:49,代码来源:templates.py

示例4: get_navbar

# 需要导入模块: from lxml.html.builder import DIV [as 别名]
# 或者: from lxml.html.builder.DIV import text [as 别名]
    def get_navbar(self, f, feeds, top=True):
        if len(feeds) < 2:
            return DIV()
        navbar = DIV("| ", CLASS("calibre_navbar", "calibre_rescale_70", style="text-align:center"))
        if not top:
            hr = HR()
            navbar.append(hr)
            navbar.text = None
            hr.tail = "| "

        if f + 1 < len(feeds):
            link = A(_("Next section"), href="../feed_%d/index.html" % (f + 1))
            link.tail = " | "
            navbar.append(link)
        link = A(_("Main menu"), href="../index.html")
        link.tail = " | "
        navbar.append(link)
        if f > 0:
            link = A(_("Previous section"), href="../feed_%d/index.html" % (f - 1))
            link.tail = " |"
            navbar.append(link)
        if top:
            navbar.append(HR())
        return navbar
开发者ID:JapaChin,项目名称:calibre,代码行数:26,代码来源:templates.py


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