%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/web/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/web/__pycache__/_template_util.cpython-312.pyc |
� Ϫ�f{ � �� � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m Z mZmZm Z mZmZmZmZmZmZ ddlmZmZ ddlmZmZ ddlmZ dd lmZ dd lmZ ddl m!Z! ddl"m#Z# dd l$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9 d� Z:de;de8de;fd�Z< G d� de)jz � Z> G d� de>� Z? G d� de)jz � Z@ G d� d e)jz � ZA G d!� d"e+� ZB G d#� d$e+� ZC G d%� d&e+� ZD G d'� d(e+� ZE G d)� d*� ZFd+ZG G d,� d-ej� ej� � ZJd.ee e eKf ded/ fd0�ZL ee9� G d1� d2� � ZM G d3� d4e+� ZNd5� ZOd6ZP e� ZQ ee9� G d7� d8� � ZR ee9� G d9� d:� � ZSh d;�ZT G d<� d=� ZU eU� ZV dCde8d>e7d?ee; d@eee#gdAf deWf dB�ZXy)DzG twisted.web.util and twisted.web.template merged to avoid cyclic deps � N)�OrderedDict��escape)�IO�Any�AnyStr�Callable�Dict�List�Mapping�Optional�Tuple�Union�cast)�handler�make_parser)�AttributesNSImpl�Locator)�implementer)�Deferred)�Logger)�urlpath)�Failure)�FilePath)�fullyQualifiedName)�resource)�Element�renderer)�Flattenable�flatten� flattenString)�CDATA�Comment�Tag�slot)�IRenderable�IRequest�ITemplateLoaderc � � dt | � � d�S )aK Wraps <pre> tags around some text and HTML-escape it. This is here since once twisted.web.html was deprecated it was hard to migrate the html.PRE from current code to twisted.web.template. For new code consider using twisted.web.template. @return: Escaped text wrapped in <pre> tags. @rtype: C{str} z<pre>z</pre>r )�texts �</usr/lib/python3/dist-packages/twisted/web/_template_util.py�_PREr, , s � � �6�$�<�.��'�'� �URL�request�returnc �� � t | t � st d� �|j dd� |j | � ddt | j d� � j d� iz }|S )a� Generate a redirect to the given location. @param URL: A L{bytes} giving the location to which to redirect. @param request: The request object to use to generate the redirect. @type request: L{IRequest<twisted.web.iweb.IRequest>} provider @raise TypeError: If the type of C{URL} a L{str} instead of L{bytes}. @return: A L{bytes} containing HTML which tries to convince the client agent to visit the new location even if it doesn't respect the I{FOUND} response code. This is intended to be returned from a render method, eg:: def render_GET(self, request): return redirectTo(b"http://example.com/", request) zURL must be bytess Content-Types text/html; charset=utf-8s� <html> <head> <meta http-equiv="refresh" content="0;URL=%(url)s"> </head> <body bgcolor="#FFFFFF" text="#000000"> <a href="%(url)s">click here</a> </body> </html> s url�utf-8)� isinstance�bytes� TypeError� setHeader�redirectr �decode�encode)r. r/ �contents r+ � redirectTor; ; sq � �( �c�5�!��+�,�,����o�'B�C����S�� � ��s�z�z�'�*�+�2�2�7�;���G� �Nr- c �8 � � e Zd ZdZdZdef� fd�Zd� Zd� Z� xZ S )�Redirectz� Resource that redirects to a specific URL. @ivar url: Redirect target URL to put in the I{Location} response header. @type url: L{bytes} T�urlc �0 �� t �| � � || _ y �N)�super�__init__r>