• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python web.htmlquote函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中web.htmlquote函数的典型用法代码示例。如果您正苦于以下问题:Python htmlquote函数的具体用法?Python htmlquote怎么用?Python htmlquote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: field_table

    def field_table(self, input, rec_amazon, rec_marc):
        yield "<table>"
        yield """<tr>
<th>Field</th>
<th>match</th>
<th>score</th>
<th>Amazon</th>
<th>MARC</th>
</tr>"""
        total = 0
        for field, match, score in input:
            yield "<tr>"
            yield "<td>%s</td>" % field
            yield "<td>%s</td>" % web.htmlquote(match)
            yield "<td>%s</td>" % score
            yield "<td>%s</td>" % as_html(rec_amazon.get(field, None))
            if field == "authors":
                authors = rec_marc.get(field, [])
                yield "<td>%s</td>" % list_to_html(web.htmlquote(a["name"]) for a in authors)
            else:
                yield "<td>%s</td>" % as_html(rec_marc.get(field, None))
            yield "</tr>"
            total += score
        yield "</table>"
        yield "threshold %d, total: %d, " % (threshold, total)
        yield (("match" if total >= threshold else "no match") + "<br>")
开发者ID:sribanta,项目名称:openlibrary,代码行数:26,代码来源:bot.py


示例2: GET

    def GET(self):
        input = web.input()
        birth = input.get('birth', '').strip()
        death = input.get('death', '').strip()
        order = input.get('order', '').strip()
        if order not in ('', 'name', 'birth', 'death'):
            order = ''
        html = '''
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Merge author</title>
<style>
body { font-family: arial,helvetica,san-serif; }
th { text-align: left; }
</style>
</head>
<body>
'''
        html += '<form method="get">\n'
        html += 'Birth: <input type="text" size="7" name="birth" value="%s">\n' % web.htmlquote(birth)
        html += 'Death: <input type="text" size="7" name="death" value="%s">\n' % web.htmlquote(death)
        html += '<input type="submit" value="Search">\n</form>'

        if birth or death:
            url = 'http://openlibrary.org/query.json?type=/type/author&birth_date=%s&death_date=%s&name=' % (web.urlquote(birth), web.urlquote(death))
            data = get_all(url)
            html += result_table(data, birth, death, order)
        return html + '</body>\n</html>'
开发者ID:internetarchive,项目名称:openlibrary,代码行数:29,代码来源:web_merge2.py


示例3: field_table

    def field_table(self, input, rec_amazon, rec_marc):
        yield '<table>'
        yield '''<tr>
<th>Field</th>
<th>match</th>
<th>score</th>
<th>Amazon</th>
<th>MARC</th>
</tr>'''
        total = 0
        for field, match, score in input:
            yield '<tr>'
            yield '<td>%s</td>' % field
            yield '<td>%s</td>' % web.htmlquote(match)
            yield '<td>%s</td>' % score
            yield '<td>%s</td>' % as_html(rec_amazon.get(field, None))
#            if field == 'number_of_pages':
#                yield '<td>%s</td>' % (web.htmlquote(rec_marc['pagination']) if 'pagination' in rec_marc else '<i>pagination missing</i>')
            if field == 'authors':
                authors = rec_marc.get(field, [])
                yield '<td>%s</td>' % list_to_html(web.htmlquote(a['name']) for a in authors)
            else:
                yield '<td>%s</td>' % as_html(rec_marc.get(field, None))
            yield '</tr>'
            total += score
        yield '</table>'
        yield 'threshold %d, total: %d, ' % (threshold, total)
        yield (('match' if total >= threshold else 'no match') + '<br>')
开发者ID:lukasklein,项目名称:openlibrary,代码行数:28,代码来源:bot.py


示例4: GET

    def GET(self):
        web.header('Content-Type','text/html; charset=utf-8', unique=True)
        input = web.input()
        title = 'Tidy author'
        if 'author' in input and input.author:
            author = input.author
            name = withKey(author)['name']
            q_name = web.htmlquote(name)
            title = q_name + ' - Tidy author'
        else:
            author = None
        ret = "<html>\n<head>\n<title>%s</title>" % title

        ret += '''
<style>
th { text-align: left }
td { padding: 5px; background: #eee }
</style>'''

        ret += '</head><body><a name="top">'
        ret += '<form name="main" method="get"><table><tr><td align="right">Author</td><td>'
        if author:
            ret += '<input type="text" name="author" value="%s">' % web.htmlquote(author)
        else:
            ret += '<input type="text" name="author">'
        ret += '</td>'
        ret += '<td><input type="submit" value="find"></td></tr>'
        ret += '</table>'
        ret += '</form>'
        if author:
            ret += 'Author: <a href="http://openlibrary.org%s">%s</a><br>' % (author, name)
            ret += search(author, name)
        ret += "</body></html>"
        return ret
开发者ID:internetarchive,项目名称:openlibrary,代码行数:34,代码来源:by_author.py


示例5: GET

    def GET(self):
        web.header('Content-Type','text/html; charset=utf-8', unique=True)
        input = web.input()
        lccn = None
        oclc = None
        isbn = None
        title = 'MARC lookup'
        if 'isbn' in input and input.isbn:
            isbn = input.isbn
            if isbn == 'random':
                isbn = random_isbn()
            title = 'MARC lookup: isbn=' + isbn
        if 'lccn' in input and input.lccn:
            lccn = input.lccn
            title = 'MARC lookup: lccn=' + lccn
        if 'oclc' in input and input.oclc:
            oclc = input.oclc
            title = 'MARC lookup: oclc=' + oclc
        ret = "<html>\n<head>\n<title>%s</title>" % title
        ret += '''
<style>
th { text-align: left }
td { padding: 5px; background: #eee }
</style>'''

        ret += '</head><body><a name="top">'
        ret += '<form name="main" method="get"><table><tr><td align="right">ISBN</td><td>'
        if isbn:
            ret += '<input type="text" name="isbn" value="%s">' % web.htmlquote(isbn)
        else:
            ret += '<input type="text" name="isbn">'
        ret += ' or <a href="/random">random</a><br>'
        ret += '</td></tr><tr><td align="right">LCCN</td><td>'
        if lccn:
            ret += '<input type="text" name="lccn" value="%s">' % web.htmlquote(lccn)
        else:
            ret += '<input type="text" name="lccn">'
        ret += '</td></tr><tr><td align="right">OCLC</td><td>'
        if oclc:
            ret += '<input type="text" name="oclc" value="%s">' % web.htmlquote(oclc)
        else:
            ret += '<input type="text" name="oclc">'
        ret += '</td></tr>'
        ret += '<tr><td></td><td><input type="submit" value="find"></td></tr>'
        ret += '</table>'
        ret += '</form>'
        if isbn:
            ret += search('isbn', isbn)
        elif lccn:
            search('lccn', lccn)
        elif oclc:
            search('oclc', oclc)
        ret += "</body></html>"
        return ret
开发者ID:hornc,项目名称:openlibrary-1,代码行数:54,代码来源:web_ui.py


示例6: GET

    def GET(self):
        web.header("Content-Type", "text/html; charset=utf-8", unique=True)
        input = web.input()
        lccn = None
        oclc = None
        isbn = None
        title = "MARC lookup"
        if "isbn" in input and input.isbn:
            isbn = input.isbn
            if isbn == "random":
                isbn = random_isbn()
            title = "MARC lookup: isbn=" + isbn
        if "lccn" in input and input.lccn:
            lccn = input.lccn
            title = "MARC lookup: lccn=" + lccn
        if "oclc" in input and input.oclc:
            oclc = input.oclc
            title = "MARC lookup: oclc=" + oclc
        print "<html>\n<head>\n<title>%s</title>" % title
        print """
<style>
th { text-align: left }
td { padding: 5px; background: #eee }
</style>"""

        print '</head><body><a name="top">'
        print '<form name="main" method="get"><table><tr><td align="right">ISBN</td><td>'
        if isbn:
            print '<input type="text" name="isbn" value="%s">' % web.htmlquote(isbn)
        else:
            print '<input type="text" name="isbn">'
        print ' or <a href="/random">random</a><br>'
        print '</td></tr><tr><td align="right">LCCN</td><td>'
        if lccn:
            print '<input type="text" name="lccn" value="%s">' % web.htmlquote(lccn)
        else:
            print '<input type="text" name="lccn">'
        print '</td></tr><tr><td align="right">OCLC</td><td>'
        if oclc:
            print '<input type="text" name="oclc" value="%s">' % web.htmlquote(oclc)
        else:
            print '<input type="text" name="oclc">'
        print "</td></tr>",
        print '<tr><td></td><td><input type="submit" value="find"></td></tr>'
        print "</table>"
        print "</form>"
        if isbn:
            search("isbn", isbn)
        elif lccn:
            search("lccn", lccn)
        elif oclc:
            search("oclc", oclc)
        print "</body></html>"
开发者ID:sribanta,项目名称:openlibrary,代码行数:53,代码来源:web_ui.py


示例7: render

 def render(self):
     out = []
     for i in self.inputs:
         if i.description != '':
             out.append('<label for="%s">%s</label><br>\n' % (i.id, web.htmlquote(i.description)))
         out.append('%s<br><br>\n' % i.render())
     return ''.join(out)
开发者ID:lobodin,项目名称:some-kinda-store,代码行数:7,代码来源:forms.py


示例8: get_web_safe_diff

def get_web_safe_diff(text1, text2):
    lines1 = text1.splitlines(True)
    lines2 = text2.splitlines(True)
    diff = []
    s = difflib.SequenceMatcher(a=lines1, b=lines2)
    commands = s.get_opcodes()
    for command, i1, i2, j1, j2 in commands:
        if command == 'replace':
            inline_diff = diff_inline(''.join(lines1[i1:i2]), ''.join(lines2[j1:j2]))
            diff.extend(inline_diff)
        elif command == 'insert':
            diff.append(DiffTag('<ins>'))
            diff.extend(lines2[j1:j2])
            diff.append(DiffTag('</ins>'))
        elif command == 'delete':
            diff.append(DiffTag('<del>'))
            diff.extend(lines1[i1:i2])
            diff.append(DiffTag('</del>'))
    escaped_diff = []
    for s in diff:
        if isinstance(s, DiffTag):
            pass
        else:
            s = web.htmlquote(s)
        escaped_diff.append(s)
    return ''.join(escaped_diff).replace('\n', '<br>\n')
开发者ID:wladich,项目名称:page2feed,代码行数:26,代码来源:htmlproc.py


示例9: GET

    def GET(self):
        web.header('Content-Type','text/html; charset=utf-8', unique=True)

        input = web.input()
        if 'oclc' in input:
            html_oclc = web.htmlquote(input.oclc)
            print "<html>\n<head><title>OCLC to MARC: %s</title><body>" % html_oclc
        else:
            print "<html>\n<head><title>OCLC to MARC</title><body>"
        print '<form method="get">'
        print 'OCLC:'
        if 'oclc' in input:
            print '<input type="text" name="oclc" value="%s">' % html_oclc
        else:
            print '<input type="text" name="oclc">'
        print '<input type="submit" value="Find MARC">'
        print '</form>'

        if 'oclc' in input:
            print 'Searching for OCLC: %s<p>' % html_oclc
            if input.oclc in dbm:
                loc = dbm[input.oclc]
                print '<ul>'
                for l in loc.split(' '):
                    print '<li><a href="http://openlibrary.org/show-marc/%s">%s</a>' % (l, l)
                print '</ul>'
            else:
                print html_oclc, 'not found'
开发者ID:RaceList,项目名称:openlibrary,代码行数:28,代码来源:lookup.py


示例10: better_diff

def better_diff(a, b):
    out = []
    a, b = html2list(a), html2list(b)
    s = difflib.SequenceMatcher(None, a, b)
    for e in s.get_opcodes():
        if e[0] == "replace":
            out.append('<span class="delete">'+ web.htmlquote(''.join(a[e[1]:e[2]])) + "</span>")
            out.append('<span class="insert">'+ web.htmlquote(''.join(b[e[3]:e[4]])) + "</span>")
        elif e[0] == "delete":
            out.append('<span class="delete">'+ web.htmlquote(''.join(a[e[1]:e[2]])) + "</span>")
        elif e[0] == "insert":
            out.append('<span class="insert">'+ web.htmlquote(''.join(b[e[3]:e[4]])) + "</span>")
        elif e[0] == "equal":
                out.append(web.htmlquote(''.join(b[e[3]:e[4]])))
    out = ''.join(out)
    return re.sub(r'(\r\n|\n|\r)', '<br />\n', out)
开发者ID:10sr,项目名称:jottit,代码行数:16,代码来源:diff.py


示例11: title_search

 def title_search(self, v):
     q = {'type': '/type/edition', 'isbn_10': None, 'title': v}
     editions = []
     for e in query_iter(q):
         e['title'] = v
         editions.append(e)
     yield 'searcing for title "' + web.htmlquote(v) + '": '
     for i in self.search(editions):
         yield i
开发者ID:lukasklein,项目名称:openlibrary,代码行数:9,代码来源:bot.py


示例12: isbn_search

 def isbn_search(self, v):
     q = {"type": "/type/edition", "isbn_10": v, "title": None, "subtitle": None}
     editions = []
     for e in query_iter(q):
         e["isbn_10"] = v
         editions.append(e)
     yield "searching for ISBN " + web.htmlquote(v) + ": "
     for i in self.search(editions):
         yield i
开发者ID:sribanta,项目名称:openlibrary,代码行数:9,代码来源:bot.py


示例13: search

    def search(self, editions):
        yield str(len(editions)) + " editions found<p>"
        yield "<table>"
        yield "<tr><th>Key</th><th>ISBN</th><th>title</th><th>subtitle</th></tr>"
        for e in editions:
            url = "http://openlibrary.org" + e["key"]
            title = web.htmlquote(e["title"]) if e["title"] else "no title"
            yield '<tr><td><a href="%s">%s</a></td>' % (url, e["key"])
            yield "<td>%s</td><td>%s</td><td>%s</td></tr>" % (
                e["isbn_10"],
                title,
                (web.htmlquote(e["subtitle"]) if e.get("subtitle", None) else "<i>no subtitle</i>"),
            )
        yield "</table><p>"

        if len(editions) == 2:
            yield "2 editions found, lets compare them<br>"
            for i in self.compare(editions):
                yield i
开发者ID:sribanta,项目名称:openlibrary,代码行数:19,代码来源:bot.py


示例14: oclc_search

 def oclc_search(self, v):
     q = {'type': '/type/edition', 'oclc_numbers': v, 'title': None, 'subtitle': None, 'isbn_10': None}
     editions = []
     print q
     for e in query_iter(q):
         e['oclc_numbers'] = v
         editions.append(e)
     yield 'searching for OCLC ' + web.htmlquote(v) + ': '
     for i in self.search(editions):
         yield i
开发者ID:lukasklein,项目名称:openlibrary,代码行数:10,代码来源:bot.py


示例15: inside_solr_select

def inside_solr_select(params):
    params.setdefault("wt", "json")
    #solr_select = solr_select_url + '?' + '&'.join("%s=%s" % (k, unicode(v)) for k, v in params)
    solr_select = solr_select_url + "?" + urllib.urlencode(params)
    stats.begin("solr", url=solr_select)

    try:
        json_data = urlopen(solr_select).read()
    except IOError, e:
        logger.error("Unable to query search inside solr", exc_info=True)
        return {"error": web.htmlquote(str(e))}
开发者ID:ahvigil,项目名称:openlibrary,代码行数:11,代码来源:code.py


示例16: _format_changes

def _format_changes(text, max=40):
    s = ''.join(text).strip()
    if len(s) > max:
        s = unicode(s, 'utf8')
        s = s[:max]
        s = s.strip()
        s = s+'...'
        s = s.encode('utf8')

    if not s: return 'whitespace'

    return '"<span class="src">%s</span>"' % web.htmlquote(s)
开发者ID:10sr,项目名称:jottit,代码行数:12,代码来源:db.py


示例17: search

    def search(self, editions):
        yield str(len(editions)) + ' editions found<p>'
        yield '<table>'
        yield '<tr><th>Key</th><th>OCLC</th><th>ISBN</th><th>title</th><th>subtitle</th></tr>'
        for e in editions:
            url = 'http://openlibrary.org' + e['key']
            title = web.htmlquote(e['title']) if e['title'] else 'no title'
            yield '<tr><td><a href="%s">%s</a></td>' % (url, e['key'])
            yield '<td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % (e['oclc_numbers'], e['isbn_10'], title, (web.htmlquote(e['subtitle']) if e.get('subtitle', None) else '<i>no subtitle</i>'))
        yield '</table><p>'

        if len(editions) == 2:
            yield '2 editions found, lets compare them<br>'
            for i in self.marc_compare(editions):
                yield i
开发者ID:lukasklein,项目名称:openlibrary,代码行数:15,代码来源:bot.py


示例18: _transform_zserv

def _transform_zserv(zserv):
    zserv['html_hostname'] = web.htmlquote(zserv['hostname'])
    zserv['url_name'] = urllib.quote(zserv['name'])
    zserv['html_name'] = web.htmlquote(zserv['name'])
    zserv['nice_type'] = nice_gamemode[zserv['type']]
    zserv['nice_wads'] = []
    for wad in zserv['wads']:
        if wad in zserv['optional_wads']:
            zserv['nice_wads'].append(wad.join(['[', ']']))
        else:
            zserv['nice_wads'].append(wad)
    zserv['joined_wads'] = ', '.join(zserv['nice_wads'])
    zserv['joined_optional_wads'] = ', '.join(zserv['optional_wads'])
    zserv['joined_maps'] = ', '.join(zserv['maps'])
    zserv['nice_type'] = nice_gamemode[zserv['type']]
    if 'map' in zserv and zserv['map']:
        if 'name' in zserv['map']:
            zserv['map']['name'] = ellipsize(zserv['map']['name'])
        if 'number' in zserv['map']:
            zserv['map']['number'] = str(zserv['map']['number']).zfill(2)
    if 'remembered_stats' in zserv:
        for m in zserv['remembered_stats']:
            m['name'] = ellipsize(m['name'])
    return zserv
开发者ID:camgunz,项目名称:zdstack,代码行数:24,代码来源:StatServer.py


示例19: GET

    def GET(self):
        web.header('Content-Type','text/html; charset=utf-8', unique=True)
        input = web.input()
        author_key = input.get('author', None)
        print "<html>\n<head>\n<title>Author fixer</title>"
        print '''
<style>
th { text-align: left }
td { padding: 5px; background: #eee }
</style>'''

        print '</head><body><a name="top">'
        print '<form name="main" method="get">'
        if author_key:
            print '<input type="text" name="author" value="%s">' % web.htmlquote(author_key)
        else:
            print '<input type="text" name="author">'
        print '<input type="submit" value="find">'
        print '</form>'
        if author_key:
            author_search(author_key)
        print "</body></html>"
开发者ID:RaceList,项目名称:openlibrary,代码行数:22,代码来源:web_ui.py


示例20: result_table

def result_table(data, birth, death, order):
    html = ' %d results' % len(data)
    l = []
    def clean(i, default, field):
        if field not in i:
            return default
        if i[field] is None:
            return ''
        m = re_year.match(i[field])
        return m.group(1) if m else i[field]

    data = [
        {
            'key': i['key'],
            'name': i['name'],
            'birth': clean(i, birth, 'birth_date'),
            'death': clean(i, death, 'death_date'),
        } for i in data]

    base_url = web.htmlquote("?birth=%s&death=%s&order=" % (web.urlquote(birth), web.urlquote(death)))
    html += '<tr>'
    html += '<th><a href="' + base_url + 'name">Name</a></th>'
    if birth:
        html += '<th>birth</th>'
    else:
        html += '<th><a href="' + base_url + 'birth">birth</a></th>'
    if death:
        html += '<th>death</th>'
    else:
        html += '<th><a href="' + base_url + 'death">death</a></th>'
    html += '</tr>'
    if order:
        data = sorted(data, key=lambda i:i[order])
    for i in data:
        html += '<tr><td><a href="http://openlibrary.org%s">%s</td><td>%s</td><td>%s</td><tr>' % (i['key'], web.htmlquote(i['name']), i['birth'], i['death'])
    return '<table>' + html + '</table>'
开发者ID:internetarchive,项目名称:openlibrary,代码行数:36,代码来源:web_merge2.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.input函数代码示例发布时间:2022-05-26
下一篇:
Python web.header函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap