Esempio n. 1
0
class _MarkupEscapeHelper(object):
    def __init__(self, obj):
        self.obj = obj

    __getitem__ = lambda s, x: _MarkupEscapeHelper(s.obj[x])
    __str__ = lambda s: str(escape(s.obj))
    __unicode__ = lambda s: unicode(escape(s.obj))
    __repr__ = lambda s: str(escape(repr(s.obj)))
    __int__ = lambda s: int(s.obj)
    __float__ = lambda s: float(s.obj)
Esempio n. 2
0
class _MarkupEscapeHelper(object):
    """Helper for Markup.__mod__"""
    def __init__(self, obj):
        self.obj = obj

    __getitem__ = lambda s, x: _MarkupEscapeHelper(s.obj[x])
    __str__ = lambda s: str(escape(s.obj))
    __unicode__ = lambda s: six.text_type(escape(s.obj))
    __repr__ = lambda s: str(escape(repr(s.obj)))
    __int__ = lambda s: int(s.obj)
    __float__ = lambda s: float(s.obj)
Esempio n. 3
0
def _escape_argspec(obj, iterable):
    """Helper for various string-wrapped functions."""
    for key, value in iterable:
        if hasattr(value, '__html__') or isinstance(value, basestring):
            obj[key] = escape(value)

    return obj
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
0
 def __radd__(self, other):
     if hasattr(other, "__html__") or isinstance(other, basestring):
         return self.__class__(unicode(escape(other)) + unicode(self))
     return NotImplemented
Esempio n. 7
0
def _escape_argspec(obj, iterable):
    """Helper for various string-wrapped functions."""
    for key, value in iterable:
        if hasattr(value, "__html__") or isinstance(value, basestring):
            obj[key] = escape(value)
    return obj
Esempio n. 8
0
 def escape(cls, s):
     rv = escape(s)
     if rv.__class__ is not cls:
         return cls(rv)
     return rv
Esempio n. 9
0
 def __radd__(self, other):
     if hasattr(other, '__html__') or isinstance(other, basestring):
         return self.__class__(unicode(escape(other)) + unicode(self))
     return NotImplemented
Esempio n. 10
0
def _escape_argspec(obj, iterable):
    for key, value in iterable:
        if hasattr(value, '__html__') or isinstance(value, basestring):
            obj[key] = escape(value)

    return obj
Esempio n. 11
0
 def escape(cls, s):
     rv = escape(s)
     if rv.__class__ is not cls:
         return cls(rv)
     return rv
Esempio n. 12
0
def _escape_argspec(obj, iterable):
    for key, value in iterable:
        if hasattr(value, '__html__') or isinstance(value, basestring):
            obj[key] = escape(value)

    return obj
Esempio n. 13
0
 def __radd__(self, other):
     if hasattr(other, '__html__') or isinstance(other, str):
         return self.__class__(str(escape(other)) + str(self))
     return NotImplemented
Esempio n. 14
0
 def __radd__(self, other):
     if hasattr(other, '__html__') or isinstance(other, str):
         return self.__class__(str(escape(other)) + str(self))
     return NotImplemented
Esempio n. 15
0
 def __radd__(self, other):
     if hasattr(other, '__html__') or isinstance(other, six.string_types):
         return self.__class__(
             six.text_type(escape(other)) + six.text_type(self))
     return NotImplemented