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


Python SPAN.tail方法代码示例

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


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

示例1: build_index

# 需要导入模块: from lxml.html.builder import SPAN [as 别名]
# 或者: from lxml.html.builder.SPAN import tail [as 别名]
def build_index(books, num, search, sort, order, start, total, url_base, CKEYS,
        prefix):
    logo = DIV(IMG(src=prefix+'/static/calibre.png', alt=__appname__), id='logo')

    search_box = build_search_box(num, search, sort, order, prefix)
    navigation = build_navigation(start, num, total, prefix+url_base)
    navigation2 = build_navigation(start, num, total, prefix+url_base)
    bookt = TABLE(id='listing')

    body = BODY(
        logo,
        search_box,
        navigation,
        HR(CLASS('spacer')),
        bookt,
        HR(CLASS('spacer')),
        navigation2
    )

    # Book list {{{
    for book in books:
        thumbnail = TD(
                IMG(type='image/jpeg', border='0',
                    src=prefix+'/get/thumb/%s' %
                            book['id']),
                CLASS('thumbnail'))

        data = TD()
        for fmt in book['formats'].split(','):
            if not fmt or fmt.lower().startswith('original_'):
                continue
            a = quote(ascii_filename(book['authors']))
            t = quote(ascii_filename(book['title']))
            s = SPAN(
                A(
                    fmt.lower(),
                    href=prefix+'/get/%s/%s-%s_%d.%s' % (fmt, a, t,
                        book['id'], fmt.lower())
                ),
                CLASS('button'))
            s.tail = u''
            data.append(s)

        div = DIV(CLASS('data-container'))
        data.append(div)

        series = u'[%s - %s]'%(book['series'], book['series_index']) \
                if book['series'] else ''
        tags = u'Tags=[%s]'%book['tags'] if book['tags'] else ''

        ctext = ''
        for key in CKEYS:
            val = book.get(key, None)
            if val:
                ctext += '%s=[%s] '%tuple(val.split(':#:'))

        first = SPAN(u'\u202f%s %s by %s' % (book['title'], series,
            book['authors']), CLASS('first-line'))
        div.append(first)
        second = SPAN(u'%s - %s %s %s' % ( book['size'],
            book['timestamp'],
            tags, ctext), CLASS('second-line'))
        div.append(second)

        bookt.append(TR(thumbnail, data))
    # }}}

    body.append(DIV(
        A(_('Switch to the full interface (non-mobile interface)'),
            href=prefix+"/browse",
            style="text-decoration: none; color: blue",
            title=_('The full interface gives you many more features, '
                'but it may not work well on a small screen')),
        style="text-align:center"))
    return HTML(
        HEAD(
            TITLE(__appname__ + ' Library'),
            LINK(rel='icon', href='http://calibre-ebook.com/favicon.ico',
                type='image/x-icon'),
            LINK(rel='stylesheet', type='text/css',
                href=prefix+'/mobile/style.css'),
            LINK(rel='apple-touch-icon', href="/static/calibre.png")
        ), # End head
        body
    ) # End html
开发者ID:BobPyron,项目名称:calibre,代码行数:87,代码来源:mobile.py

示例2: build_index

# 需要导入模块: from lxml.html.builder import SPAN [as 别名]
# 或者: from lxml.html.builder.SPAN import tail [as 别名]
def build_index(books, num, search, sort, order, start, total, url_base, CKEYS, prefix, have_kobo_browser=False):
    logo = DIV(IMG(src=prefix + "/static/calibre.png", alt=__appname__), id="logo")

    search_box = build_search_box(num, search, sort, order, prefix)
    navigation = build_navigation(start, num, total, prefix + url_base)
    navigation2 = build_navigation(start, num, total, prefix + url_base)
    bookt = TABLE(id="listing")

    body = BODY(logo, search_box, navigation, HR(CLASS("spacer")), bookt, HR(CLASS("spacer")), navigation2)

    # Book list {{{
    for book in books:
        thumbnail = TD(
            IMG(type="image/jpeg", border="0", src=prefix + "/get/thumb/%s" % book["id"]), CLASS("thumbnail")
        )

        data = TD()
        for fmt in book["formats"].split(","):
            if not fmt or fmt.lower().startswith("original_"):
                continue
            file_extension = "kepub.epub" if have_kobo_browser and fmt.lower() == "kepub" else fmt
            a = quote(ascii_filename(book["authors"]))
            t = quote(ascii_filename(book["title"]))
            s = SPAN(
                A(fmt.lower(), href=prefix + "/get/%s/%s-%s_%d.%s" % (fmt, a, t, book["id"], file_extension.lower())),
                CLASS("button"),
            )
            s.tail = u""
            data.append(s)

        div = DIV(CLASS("data-container"))
        data.append(div)

        series = u"[%s - %s]" % (book["series"], book["series_index"]) if book["series"] else ""
        tags = u"Tags=[%s]" % book["tags"] if book["tags"] else ""

        ctext = ""
        for key in CKEYS:
            val = book.get(key, None)
            if val:
                ctext += "%s=[%s] " % tuple(val.split(":#:"))

        first = SPAN(
            u"\u202f%s %s by %s"
            % (clean_xml_chars(book["title"]), clean_xml_chars(series), clean_xml_chars(book["authors"])),
            CLASS("first-line"),
        )
        div.append(first)
        second = SPAN(u"%s - %s %s %s" % (book["size"], book["timestamp"], tags, ctext), CLASS("second-line"))
        div.append(second)

        bookt.append(TR(thumbnail, data))
    # }}}

    body.append(
        DIV(
            A(
                _("Switch to the full interface (non-mobile interface)"),
                href=prefix + "/browse",
                style="text-decoration: none; color: blue",
                title=_(
                    "The full interface gives you many more features, " "but it may not work well on a small screen"
                ),
            ),
            style="text-align:center",
        )
    )
    return HTML(
        HEAD(
            TITLE(__appname__ + " Library"),
            LINK(rel="icon", href="//calibre-ebook.com/favicon.ico", type="image/x-icon"),
            LINK(rel="stylesheet", type="text/css", href=prefix + "/mobile/style.css"),
            LINK(rel="apple-touch-icon", href="/static/calibre.png"),
            META(name="robots", content="noindex"),
        ),  # End head
        body,
    )  # End html
开发者ID:Xliff,项目名称:calibre,代码行数:79,代码来源:mobile.py


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