ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/wsgiref/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/wsgiref/__pycache__/validate.cpython-35.opt-2.pyc



���];;�@sHdgZddlZddlZddlZejd�Zejd�ZGdd�de�Zdd�Z	d	d
�Z
dd�ZGdd
�d
�ZGdd�d�Z
Gdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)&�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdS)�WSGIWarningN)�__name__�
__module__�__qualname__�rr�-/opt/alt/python35/lib64/python3.5/validate.pyrysrcGs|st|��dS)N)�AssertionError)Zcond�argsrrr�assert_~srcCs8t|�tkr|Stdj|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr	�format�repr)�value�titlerrr�check_string_type�srcs�fdd�}|S)Ncs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	o�|dkd	�t|�t|��S)
N�zTwo arguments requiredzNo keyword arguments allowedcs�tt|�dkp$t|�dkd|f�t|d�|d}|d}t|�dkrs|d}nd}t|�t|�t||�t|��jd�t�|��S)Nr�zInvalid number of arguments: %szNo keyword arguments allowedr�)r�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r
�kw�status�headers�exc_info)�start_response�start_response_startedrr�start_response_wrapper�s$







z;validator.<locals>.lint_app.<locals>.start_response_wrapperz
wsgi.inputzwsgi.errorsFz>The application must return an iterator, if only an empty list)rr�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)r
r�environr#�iterator)�application)r!r"r�lint_app�s

zvalidator.<locals>.lint_appr)r+r,r)r+rr�s)c@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r%cCs
||_dS)N)�input)�self�
wsgi_inputrrr�__init__�szInputWrapper.__init__cGsBtt|�dk�|jj|�}tt|�tk�|S)Nr)rrr-�readr�bytes)r.r
�vrrrr1�szInputWrapper.readcGsBtt|�dk�|jj|�}tt|�tk�|S)Nr)rrr-�readlinerr2)r.r
r3rrrr4�szInputWrapper.readlinecGsitt|�dk�|jj|�}tt|�tk�x$|D]}tt|�tk�qEW|S)Nr)rrr-�	readlinesr�listr2)r.r
�lines�linerrrr5�s
zInputWrapper.readlinesccs&x|j�}|sdS|VqWdS)N)r4)r.r8rrr�__iter__�s
zInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called)r)r.rrr�close�szInputWrapper.closeN)	rrrr0r1r4r5r9r:rrrrr%�sr%c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r&cCs
||_dS)N)�errors)r.�wsgi_errorsrrrr0�szErrorWrapper.__init__cCs*tt|�tk�|jj|�dS)N)rrr
r;�write)r.�srrrr=�szErrorWrapper.writecCs|jj�dS)N)r;�flush)r.rrrr?�szErrorWrapper.flushcCs"x|D]}|j|�qWdS)N)r=)r.�seqr8rrr�
writelines�s
zErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be called)r)r.rrrr:�szErrorWrapper.closeN)rrrr0r=r?rAr:rrrrr&�s
r&c@s(eZdZdd�Zdd�ZdS)rcCs
||_dS)N)�writer)r.Zwsgi_writerrrrr0�szWriteWrapper.__init__cCs'tt|�tk�|j|�dS)N)rrr2rB)r.r>rrr�__call__�szWriteWrapper.__call__N)rrrr0rCrrrrr�src@s(eZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dS)N)r*)r.�
wsgi_iteratorrrrr0szPartialIteratorWrapper.__init__cCst|jd�S)N)r(r*)r.rrrr9szPartialIteratorWrapper.__iter__N)rrrr0r9rrrrrD�srDc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r(cCs.||_t|�|_d|_||_dS)NF)�original_iterator�iterr*�closed�check_start_response)r.rErIrrrr0	s		zIteratorWrapper.__init__cCs|S)Nr)r.rrrr9szIteratorWrapper.__iter__cCsrt|jd�t|j�}t|�tk	rFtdd|f�|jdk	rnt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrH�nextr*rr2rI)r.r3rrr�__next__s
		zIteratorWrapper.__next__cCs,d|_t|jd�r(|jj�dS)NTr:)rH�hasattrrFr:)r.rrrr:s	zIteratorWrapper.closecCs-|jstjjd�t|jd�dS)Nz/Iterator garbage collected without being closed)rH�sys�stderrr=r)r.rrr�__del__#s
			zIteratorWrapper.__del__N)rrrr0r9rKr:rOrrrrr(s
r(c	Cs�tt|�tkdt|�|f�xCdddddddd	d
g	D] }t||kd|f�qKWx;dd
gD]-}t||kd||dd�f�q|Wd|kr�tjdt�x[|j�D]M}d|kr�q�tt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd,kd|d�t	|d�t
|d�|dd-kr�tjd!|dt�t|jd"�p�|d"jd#�d$|d"�t|jd%�p|d%jd#�d&|d%�|jd'�rJtt
|d'�d(kd)|d'�|jd"�sltd%|kd*�t|jd"�d#kd+�dS).Nz:Environment is not of the right type: %r (environment: %r)ZREQUEST_METHODZSERVER_NAMEZSERVER_PORTzwsgi.versionz
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocessz
wsgi.run_oncez$Environment missing required key: %rZHTTP_CONTENT_TYPEZHTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)z#wsgi.version should be a tuple (%r)zwsgi.url_scheme�http�httpszwsgi.url_scheme unknown: %r�GET�HEAD�POST�OPTIONS�PATCH�PUT�DELETE�TRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')rRrS)rTrUrVrWrXrYrZr[)rr�dict�warnings�warnr�keysr
�tuple�check_input�check_errors�get�
startswith�int)r)�keyrrrr$*s`	
#	r$cCsAx:ddddgD]&}tt||�d||f�qWdS)Nr1r4r5r9z-wsgi.input (%r) doesn't have the attribute %s)rrL)r/�attrrrrrbksrbcCs>x7dddgD]&}tt||�d||f�qWdS)Nr?r=rAz.wsgi.errors (%r) doesn't have the attribute %s)rrL)r<rhrrrrcqsrccCs�t|d�}|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dks�|dd	kr�tjd
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitrrrfr^r_r)rZstatus_codeZ
status_intrrrrws"rcCsztt|�tkd|t|�f�i}xD|D]<}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|j�dkd|�d||j�<td|ko�d	|kd
|�ttj|�d|�t|j	d�o/|j	d
�d|�t
j|�r6tdd|t
j|�jd�f�q6WdS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rrzHeader namezHeader valuerzyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))rrr6rarr�lower�	header_re�search�endswith�bad_header_value_re�group)rZheader_names�item�namerrrrr�s0
 	rcCs�t|d�}t|jdd�d�}d
}xV|D]N\}}t|d�}|j�dkr8||krudStdd|�q8W||kr�tdd	|�dS)Nrirr���0zHeader namezcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))rzr{)rrfrmrrr)rr�codeZNO_MESSAGE_BODYryrrrrr�s	rcCs9t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)rrra)r rrrr�srcCs!tt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r�
isinstancer
r2)r*rrrr'�sr')�__all__�rerMr^�compilersrv�Warningrrrrr%r&rrDr(r$rbrcrrrrr'rrrr�<module>os,	7#		#A

Zerion Mini Shell 1.0