Python markupsafe._speedups 模块,escape() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用markupsafe._speedups.escape()

项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
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))
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
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))
项目:Indushell    作者:SecarmaLabs    | 项目源码 | 文件源码
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))
项目:Liljimbo-Chatbot    作者:chrisjim316    | 项目源码 | 文件源码
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))
项目:flask_system    作者:prashasy    | 项目源码 | 文件源码
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))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def __radd__(self, other):
        if hasattr(other, '__html__') or isinstance(other, string_types):
            return self.escape(other).__add__(self)
        return NotImplemented
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq)))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep))))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def __init__(self, escape):
            self.escape = escape
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def __init__(self, obj, escape):
        self.obj = obj
        self.escape = escape
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def __radd__(self, other):
        if hasattr(other, '__html__') or isinstance(other, string_types):
            return self.escape(other).__add__(self)
        return NotImplemented
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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))
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq)))
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep))))
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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))
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def __init__(self, escape):
            self.escape = escape
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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))
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def __init__(self, obj, escape):
        self.obj = obj
        self.escape = escape
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def __radd__(self, other):
        if hasattr(other, '__html__') or isinstance(other, string_types):
            return self.escape(other).__add__(self)
        return NotImplemented
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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))
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq)))
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep))))
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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))
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def __init__(self, escape):
            self.escape = escape
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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))
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def __init__(self, obj, escape):
        self.obj = obj
        self.escape = escape
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def __radd__(self, other):
        if hasattr(other, '__html__') or isinstance(other, string_types):
            return self.escape(other).__add__(self)
        return NotImplemented
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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))
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq)))
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep))))
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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))
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def __init__(self, escape):
            self.escape = escape
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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))
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def __init__(self, obj, escape):
        self.obj = obj
        self.escape = escape
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
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