3 \;;@sdgZddlZddlZddlZejdZejdZGdddeZddZ d d Z d dZ Gd d d Z GdddZ GdddZGdddZGdddZddZddZddZddZddZd d!Zd"d#Zd$d%ZdS)& validatorNz^[a-zA-Z][a-zA-Z0-9\-_]*$z [\000-\037]c@s eZdZdS) WSGIWarningN)__name__ __module__ __qualname__rr(/usr/lib64/python3.6/wsgiref/validate.pyrysrcGs|s t|dS)N)AssertionError)Zcondargsrrrassert_~sr cCs(t|tkr|Stdj|t|dS)Nz!{0} must be of type str (got {1}))typestrr formatrepr)valuetitlerrrcheck_string_types rcsfdd}|S)Ncstt|dkdt| d|\}t|gfdd}t|d|d<t|d|d<||}t|dk oz|dkd t|t|S) NzTwo arguments requiredzNo keyword arguments allowedcstt|dkpt|dkd|ft| d|d}|d}t|dkrV|d}nd}t|t|t||t|jdt|S)NrzInvalid number of arguments: %szNo keyword arguments allowedr)r len check_status check_headerscheck_content_typecheck_exc_infoappend WriteWrapper)r kwstatusheadersexc_info)start_responsestart_response_startedrrstart_response_wrappers      z;validator..lint_app..start_response_wrapperz wsgi.inputz wsgi.errorsFz>The application must return an iterator, if only an empty list)r r check_environ InputWrapper ErrorWrappercheck_iteratorIteratorWrapper)r renvironr#iterator) application)r!r"rlint_apps  zvalidator..lint_appr)r+r,r)r+rrs )c@s<eZdZddZddZddZddZd d Zd d Zd S)r%cCs ||_dS)N)input)self wsgi_inputrrr__init__szInputWrapper.__init__cGs0tt|dk|jj|}tt|tk|S)Nr)r rr-readr bytes)r.r vrrrr1s zInputWrapper.readcGs0tt|dk|jj|}tt|tk|S)Nr)r rr-readliner r2)r.r r3rrrr4s zInputWrapper.readlinecGsNtt|dk|jj|}tt|tkx|D]}tt|tkq2W|S)Nr)r rr- readlinesr listr2)r.r lineslinerrrr5s   zInputWrapper.readlinesccs x|j}|sdS|VqWdS)N)r4)r.r8rrr__iter__s zInputWrapper.__iter__cCstdddS)Nrz input.close() must not be called)r )r.rrrcloseszInputWrapper.closeN) rrrr0r1r4r5r9r:rrrrr%s r%c@s4eZdZddZddZddZddZd d Zd S) r&cCs ||_dS)N)errors)r. wsgi_errorsrrrr0szErrorWrapper.__init__cCs tt|tk|jj|dS)N)r r r r;write)r.srrrr=szErrorWrapper.writecCs|jjdS)N)r;flush)r.rrrr?szErrorWrapper.flushcCsx|D]}|j|qWdS)N)r=)r.seqr8rrr writeliness zErrorWrapper.writelinescCstdddS)Nrz!errors.close() must not be called)r )r.rrrr:szErrorWrapper.closeN)rrrr0r=r?rAr:rrrrr&s r&c@seZdZddZddZdS)rcCs ||_dS)N)writer)r.Z wsgi_writerrrrr0szWriteWrapper.__init__cCstt|tk|j|dS)N)r r r2rB)r.r>rrr__call__szWriteWrapper.__call__N)rrrr0rCrrrrrsrc@seZdZddZddZdS)PartialIteratorWrappercCs ||_dS)N)r*)r. wsgi_iteratorrrrr0szPartialIteratorWrapper.__init__cCs t|jdS)N)r(r*)r.rrrr9szPartialIteratorWrapper.__iter__N)rrrr0r9rrrrrDsrDc@s4eZdZddZddZddZddZd d Zd S) r(cCs ||_t||_d|_||_dS)NF)original_iteratoriterr*closedcheck_start_response)r.rErIrrrr0 s zIteratorWrapper.__init__cCs|S)Nr)r.rrrr9szIteratorWrapper.__iter__cCsTt|j dt|j}t|tk r4tdd|f|jdk rPt|jdd|_|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)r rHnextr*r r2rI)r.r3rrr__next__s   zIteratorWrapper.__next__cCs d|_t|jdr|jjdS)NTr:)rHhasattrrFr:)r.rrrr:s zIteratorWrapper.closecCs"|jstjjdt|jddS)Nz/Iterator garbage collected without being closed)rHsysstderrr=r )r.rrr__del__#s zIteratorWrapper.__del__N)rrrr0r9rKr:rOrrrrr(s  r(c Cstt|tkdt||fx d,D]}t||kd |fq$Wx*d-D]"}t||kd||ddfqFWd|krtjdtxF|jD]:}d|krqtt||tkd|t||||fqWtt|dtkd|dft|dd.kd|dt |dt |d|dd/kros,  7#  #A