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


Python _native.escape方法代碼示例

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


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

示例1: format_field

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def format_field(self, value, format_spec):
            if hasattr(value, '__html_format__'):
                rv = value.__html_format__(format_spec)
            elif hasattr(value, '__html__'):
                if format_spec:
                    raise ValueError('No format specification allowed '
                                     'when formatting an object with '
                                     'its __html__ method.')
                rv = value.__html__()
            else:
                # We need to make sure the format spec is unicode here as
                # otherwise the wrong callback methods are invoked.  For
                # instance a byte string there would invoke __str__ and
                # not __unicode__.
                rv = string.Formatter.format_field(
                    self, value, text_type(format_spec))
            return text_type(self.escape(rv)) 
開發者ID:liantian-cn,項目名稱:RSSNewsGAE,代碼行數:19,代碼來源:__init__.py

示例2: __add__

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def __add__(self, other):
        if isinstance(other, string_types) or hasattr(other, '__html__'):
            return self.__class__(super(Markup, self).__add__(self.escape(other)))
        return NotImplemented 
開發者ID:jpush,項目名稱:jbox,代碼行數:6,代碼來源:__init__.py

示例3: __radd__

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def __radd__(self, other):
        if hasattr(other, '__html__') or isinstance(other, string_types):
            return self.escape(other).__add__(self)
        return NotImplemented 
開發者ID:jpush,項目名稱:jbox,代碼行數:6,代碼來源:__init__.py

示例4: __mod__

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def __mod__(self, arg):
        if isinstance(arg, tuple):
            arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg)
        else:
            arg = _MarkupEscapeHelper(arg, self.escape)
        return self.__class__(text_type.__mod__(self, arg)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:8,代碼來源:__init__.py

示例5: join

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq))) 
開發者ID:jpush,項目名稱:jbox,代碼行數:4,代碼來源:__init__.py

示例6: escape

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def escape(cls, s):
        """Escape the string.  Works like :func:`escape` with the difference
        that for subclasses of :class:`Markup` this function would return the
        correct subclass.
        """
        rv = escape(s)
        if rv.__class__ is not cls:
            return cls(rv)
        return rv 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:__init__.py

示例7: partition

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep)))) 
開發者ID:jpush,項目名稱:jbox,代碼行數:5,代碼來源:__init__.py

示例8: rpartition

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6 
開發者ID:jpush,項目名稱:jbox,代碼行數:7,代碼來源:__init__.py

示例9: format

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def format(*args, **kwargs):
            self, args = args[0], args[1:]
            formatter = EscapeFormatter(self.escape)
            kwargs = _MagicFormatMapping(args, kwargs)
            return self.__class__(formatter.vformat(self, args, kwargs)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:7,代碼來源:__init__.py

示例10: __init__

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

示例11: format_field

# 需要導入模塊: from markupsafe import _native [as 別名]
# 或者: from markupsafe._native import escape [as 別名]
def format_field(self, value, format_spec):
            if hasattr(value, '__html_format__'):
                rv = value.__html_format__(format_spec)
            elif hasattr(value, '__html__'):
                if format_spec:
                    raise ValueError('No format specification allowed '
                                     'when formatting an object with '
                                     'its __html__ method.')
                rv = value.__html__()
            else:
                rv = string.Formatter.format_field(self, value, format_spec)
            return text_type(self.escape(rv)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:__init__.py


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