Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/twisted/web/__pycache__/_template_util.cpython-39.pyc
Ðазад
a k�h�z � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m Z mZmZm Z mZmZmZmZmZmZ ddlmZmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlm Z ddl!m"Z" dd l#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6m7Z7m8Z8 dd� Z9e:e7e:d�dd�Z;G dd� de(j<�Z=G dd� de=�Z>G dd� de(j<�Z?G dd � d e(j<�Z@G d!d"� d"e*�ZAG d#d$� d$e*�ZBG d%d&� d&e*�ZCG d'd(� d(e*�ZDG d)d*� d*�ZEd+ZFG d,d-� d-ejGejH�ZIee e eJf ed. d/�d0d1�ZKee8�G d2d3� d3��ZLG d4d5� d5e*�ZMd6d7� ZNd8ZOe� ZPee8�G d9d:� d:��ZQee8�G d;d<� d<��ZRh d=�ZSG d>d?� d?�ZTeT� ZUdEe7e6ee: eee"gdAf eVdB�dCdD�ZWdS )FzG 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)�Locator)�implementer)�Deferred)�Logger)�urlpath)�Failure)�FilePath)�fullyQualifiedName)�resource)�Element�renderer)�Flattenable�flatten� flattenString)�CDATA�Comment�Tag�slot)�IRenderable�IRequest�ITemplateLoaderc C s 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 )�text� r( ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/twisted/web/_template_util.py�_PRE, s r* )�URL�request�returnc C s8 t | t�std��|�dd� |�| � dd| i }|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)� isinstance�bytes� TypeErrorZ setHeader�redirect)r+ r, �contentr( r( r) � redirectTo; s ��r3 c s: e Zd ZdZdZed�� fdd�Zdd� Zdd � Z� Z 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 s t � �� || _d S �N)�super�__init__r5 ��selfr5 �� __class__r( r) r8 n s zRedirect.__init__c C s t | j|�S r6 )r3 r5 )r: r, r( r( r) �renderr s zRedirect.renderc C s | S r6 r( �r: �namer, r( r( r) �getChildu s zRedirect.getChild) �__name__� __module__�__qualname__�__doc__�isLeafr/ r8 r= r@ � __classcell__r( r( r; r) r4 d s r4 c @ s e Zd ZdZdd� Zdd� ZdS )�ChildRedirectorFc C s>