當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.escape方法代碼示例

本文整理匯總了Python中werkzeug.utils.escape方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.escape方法的具體用法?Python utils.escape怎麽用?Python utils.escape使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在werkzeug.utils的用法示例。


在下文中一共展示了utils.escape方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: render_line_context

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def render_line_context(self):
        before, current, after = self.get_context_lines()
        rv = []

        def render_line(line, cls):
            line = line.expandtabs().rstrip()
            stripped_line = line.strip()
            prefix = len(line) - len(stripped_line)
            rv.append(
                '<pre class="line %s"><span class="ws">%s</span>%s</pre>' % (
                    cls, ' ' * prefix, escape(stripped_line) or ' '))

        for line in before:
            render_line(line, 'before')
        render_line(current, 'current')
        for line in after:
            render_line(line, 'after')

        return '\n'.join(rv) 
開發者ID:jpush,項目名稱:jbox,代碼行數:21,代碼來源:tbtools.py

示例2: runsource

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def runsource(self, source):
        source = source.rstrip() + '\n'
        ThreadedStream.push()
        prompt = self.more and '... ' or '>>> '
        try:
            source_to_eval = ''.join(self.buffer + [source])
            if code.InteractiveInterpreter.runsource(self,
                                                     source_to_eval, '<debugger>', 'single'):
                self.more = True
                self.buffer.append(source)
            else:
                self.more = False
                del self.buffer[:]
        finally:
            output = ThreadedStream.fetch()
        return prompt + escape(source) + output 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:18,代碼來源:console.py

示例3: render_full

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def render_full(self, evalex=False, secret=None,
                    evalex_trusted=True):
        """Render the Full HTML page with the traceback info."""
        exc = escape(self.exception)
        return PAGE_HTML % {
            'evalex':           evalex and 'true' or 'false',
            'evalex_trusted':   evalex_trusted and 'true' or 'false',
            'console':          'false',
            'title':            exc,
            'exception':        exc,
            'exception_type':   escape(self.exception_type),
            'summary':          self.render_summary(include_title=False),
            'plaintext':        escape(self.plaintext),
            'plaintext_cs':     re.sub('-{2,}', '-', self.plaintext),
            'traceback_id':     self.id,
            'secret':           secret
        } 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:19,代碼來源:tbtools.py

示例4: get_description

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def get_description(self, environ=None):
        """Get the description."""
        return u'<p>%s</p>' % escape(self.description) 
開發者ID:jpush,項目名稱:jbox,代碼行數:5,代碼來源:exceptions.py

示例5: get_body

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def get_body(self, environ=None):
        """Get the HTML body."""
        return text_type((
            u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
            u'<title>%(code)s %(name)s</title>\n'
            u'<h1>%(name)s</h1>\n'
            u'%(description)s\n'
        ) % {
            'code':         self.code,
            'name':         escape(self.name),
            'description':  self.get_description(environ)
        }) 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:exceptions.py

示例6: write

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def write(self, x):
        self._write(escape(x)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:4,代碼來源:console.py

示例7: writelines

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def writelines(self, x):
        self._write(escape(''.join(x))) 
開發者ID:jpush,項目名稱:jbox,代碼行數:4,代碼來源:console.py

示例8: regex_repr

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def regex_repr(self, obj):
        pattern = repr(obj.pattern)
        if PY2:
            pattern = pattern.decode('string-escape', 'ignore')
        else:
            pattern = codecs.decode(pattern, 'unicode-escape', 'ignore')
        if pattern[:1] == 'u':
            pattern = 'ur' + pattern[1:]
        else:
            pattern = 'r' + pattern
        return u're.compile(<span class="string regex">%s</span>)' % pattern 
開發者ID:jpush,項目名稱:jbox,代碼行數:13,代碼來源:repr.py

示例9: object_repr

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def object_repr(self, obj):
        r = repr(obj)
        if PY2:
            r = r.decode('utf-8', 'replace')
        return u'<span class="object">%s</span>' % escape(r) 
開發者ID:jpush,項目名稱:jbox,代碼行數:7,代碼來源:repr.py

示例10: fallback_repr

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def fallback_repr(self):
        try:
            info = ''.join(format_exception_only(*sys.exc_info()[:2]))
        except Exception:  # pragma: no cover
            info = '?'
        if PY2:
            info = info.decode('utf-8', 'ignore')
        return u'<span class="brokenrepr">&lt;broken repr (%s)&gt;' \
               u'</span>' % escape(info.strip()) 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:repr.py

示例11: render_object_dump

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def render_object_dump(self, items, title, repr=None):
        html_items = []
        for key, value in items:
            html_items.append('<tr><th>%s<td><pre class=repr>%s</pre>' %
                              (escape(key), value))
        if not html_items:
            html_items.append('<tr><td><em>Nothing</em>')
        return OBJECT_DUMP_HTML % {
            'title':    escape(title),
            'repr':     repr and '<pre class=repr>%s</pre>' % repr or '',
            'items':    '\n'.join(html_items)
        } 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:repr.py

示例12: render

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def render(self):
        return SOURCE_LINE_HTML % {
            'classes':      u' '.join(self.classes),
            'lineno':       self.lineno,
            'code':         escape(self.code)
        } 
開發者ID:jpush,項目名稱:jbox,代碼行數:8,代碼來源:tbtools.py

示例13: render_summary

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def render_summary(self, include_title=True):
        """Render the traceback for the interactive console."""
        title = ''
        frames = []
        classes = ['traceback']
        if not self.frames:
            classes.append('noframe-traceback')

        if include_title:
            if self.is_syntax_error:
                title = u'Syntax Error'
            else:
                title = u'Traceback <em>(most recent call last)</em>:'

        for frame in self.frames:
            frames.append(u'<li%s>%s' % (
                frame.info and u' title="%s"' % escape(frame.info) or u'',
                frame.render()
            ))

        if self.is_syntax_error:
            description_wrapper = u'<pre class=syntaxerror>%s</pre>'
        else:
            description_wrapper = u'<blockquote>%s</blockquote>'

        return SUMMARY_HTML % {
            'classes':      u' '.join(classes),
            'title':        title and u'<h3>%s</h3>' % title or u'',
            'frames':       u'\n'.join(frames),
            'description':  description_wrapper % escape(self.exception)
        } 
開發者ID:jpush,項目名稱:jbox,代碼行數:33,代碼來源:tbtools.py

示例14: _make_text_block

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def _make_text_block(name, content, content_type=None):
    """Helper function for the builder that creates an XML text block."""
    if content_type == 'xhtml':
        return u'<%s type="xhtml"><div xmlns="%s">%s</div></%s>\n' % \
               (name, XHTML_NAMESPACE, content, name)
    if not content_type:
        return u'<%s>%s</%s>\n' % (name, escape(content), name)
    return u'<%s type="%s">%s</%s>\n' % (name, content_type,
                                         escape(content), name) 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:atom.py

示例15: string_repr

# 需要導入模塊: from werkzeug import utils [as 別名]
# 或者: from werkzeug.utils import escape [as 別名]
def string_repr(self, obj, limit=70):
        buf = ['<span class="string">']
        a = repr(obj[:limit])
        b = repr(obj[limit:])
        if isinstance(obj, text_type) and PY2:
            buf.append('u')
            a = a[1:]
            b = b[1:]
        if b != "''":
            buf.extend((escape(a[:-1]), '<span class="extended">', escape(b[1:]), '</span>'))
        else:
            buf.append(escape(a))
        buf.append('</span>')
        return _add_subclass_info(u''.join(buf), obj, (bytes, text_type)) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:16,代碼來源:repr.py


注:本文中的werkzeug.utils.escape方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。