当前位置: 首页>>代码示例>>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;未经允许,请勿转载。