Current File : //proc/self/root/lib/python3/dist-packages/twisted/web/__pycache__/_flatten.cpython-312.pyc |
�
Ϫ�f�F � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZmZmZmZmZmZmZmZmZmZmZ dd lmZmZ dd
lmZ ddlm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' dd
l(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z. ed� Z/eZ0 ee1e2e&e"e$e%ee0df ee0 ee0ddf e#ee0 eee0 e3e0f e-f
Z4 dZ5dd�Z6dd�Z7 dd�Z8dd�Z9dd�Z: d d!d�Z;d"d�Z< d#d�Z= d$d�Z> d%d�Z?d&d�Z@y)'zu
Context-free flattener/serializer for rendering Python objects, possibly
complex or arbitrarily nested, as strings.
� )�annotations)�iscoroutine)�BytesIO)�exc_info)�
extract_tb)�
GeneratorType)�Any�Callable� Coroutine� Generator�List�Mapping�Optional�Sequence�Tuple�TypeVar�Union�cast)�Deferred�ensureDeferred)�nativeString)�Failure)�CDATA�CharRef�Comment�Tag�slot�voidElements)�FlattenerError�UnfilledSlot�UnsupportedType)�IRenderable�IRequest�T.Ni c � � t | t � r| j d� } | j dd� j dd� j dd� } | S )a�
Escape some character or UTF-8 byte data for inclusion in an HTML or XML
document, by replacing metacharacters (C{&<>}) with their entity
equivalents (C{&<>}).
This is used as an input to L{_flattenElement}'s C{dataEscaper} parameter.
@param data: The string to escape.
@return: The quoted form of C{data}. If C{data} is L{str}, return a utf-8
encoded string.
�utf-8� &s &� <s <� >s >��
isinstance�str�encode�replace��datas �6/usr/lib/python3/dist-packages/twisted/web/_flatten.py�escapeForContentr2 G sK � � �$����{�{�7�#���<�<��h�'�/�/��g�>�F�F�t�W�U�D��K� c �H � t | t � r| j d� S | S )aG
Escape some character or UTF-8 byte data for inclusion in the top level of
an attribute. L{attributeEscapingDoneOutside} actually passes the data
through unchanged, because L{writeWithAttributeEscaping} handles the
quoting of the text within attributes outside the generator returned by
L{_flattenElement}; this is used as the C{dataEscaper} argument to that
L{_flattenElement} call so that that generator does not redundantly escape
its text output.
@param data: The string to escape.
@return: The string, unchanged, except for encoding.
r&