python类escape()的实例源码

__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq)))
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep))))
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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))
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def __init__(self, escape):
            self.escape = escape
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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))
__init__.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, obj, escape):
        self.obj = obj
        self.escape = escape
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __radd__(self, other):
        if hasattr(other, '__html__') or isinstance(other, string_types):
            return self.escape(other).__add__(self)
        return NotImplemented
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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))
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def join(self, seq):
        return self.__class__(text_type.join(self, map(self.escape, seq)))
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def partition(self, sep):
            return tuple(map(self.__class__,
                             text_type.partition(self, self.escape(sep))))
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def rpartition(self, sep):
            return tuple(map(self.__class__,
                             text_type.rpartition(self, self.escape(sep))))

    # new in python 2.6
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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))
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self, escape):
            self.escape = escape
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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))
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, obj, escape):
        self.obj = obj
        self.escape = escape
__init__.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号