ϪfV5dZgdZddlmZddlmZmZmZddlm Z ddl m Z dee e fdee fd ZGd d eZGd d eZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGd d!eZGd"d#eZGd$d%eZGd&d'eZy())z+ Exception definitions for L{twisted.web}. ) Error PageRedirectInfiniteRedirection RenderErrorMissingRenderMethodMissingTemplateLoaderUnexposedMethodError UnfilledSlotUnsupportedTypeFlattenerErrorRedirectWithNoLocation)Sequence)OptionalUnioncast) nativeString) RESPONSEScodereturncj tjt|S#ttf$rYywxYw)z Returns the response message corresponding to an HTTP code, or None if the code is unknown or unrecognized. @param code: HTTP status code, for example C{http.NOT_FOUND}. @return: A string message or none N)rgetint ValueErrorAttributeError)rs 3/usr/lib/python3/dist-packages/twisted/web/error.py_codeToMessagers1}}SY''  's  22c |eZdZUdZeed<eeed<eeed< d deeefdeedeeddfdZ de fd Z y) rz A basic HTTP error. @ivar status: Refers to an HTTP status code, for example C{http.NOT_FOUND}. @param message: A short error message, for example "NOT FOUND". @ivar response: A complete HTML document for an error page. statusmessageresponseNrrc|xs t|}tj||||t|trd|fz}n,t |dk7s|j std|||_||_ ||_ y)a- Initializes a basic exception. @type code: L{bytes} or L{int} @param code: Refers to an HTTP status code (for example, 200) either as an integer or a bytestring representing such. If no C{message} is given, C{code} is mapped to a descriptive bytestring that is used instead. @type message: L{bytes} @param message: A short error message, for example C{b"NOT FOUND"}. @type response: L{bytes} @param response: A complete HTML document for an error page. s%dzNot a valid HTTP status code: N) r Exception__init__ isinstancerlenisdigitrrrr )selfrrr s rr$zError.__init__=s{,1^D14w9 dC D7?D Y!^4<<>=dXFG G    cl|j}|jr|d|jzz }t|S)N )rrr)r(ss r__str__z Error.__str__es/ KK <<  $ $AAr))NN) __name__ __module__ __qualname____doc__bytes__annotations__rrrr$strr-r)rrr.ss M e_uo $($( &!CJ&!%&!5/ &!  &!Pr)rc beZdZUdZeeed< d deeefdeedeedeeddf dZ y) rz{ A request resulted in an HTTP redirect. @ivar location: The location of the redirect which was not followed. locationNrrr rctj|||||jr|r|jdz|z|_||_y)a Initializes a page redirect exception. @type code: L{bytes} @param code: Refers to an HTTP status code, for example C{http.NOT_FOUND}. If no C{message} is given, C{code} is mapped to a descriptive string that is used instead. @type message: L{bytes} @param message: A short error message, for example C{b"NOT FOUND"}. @type response: L{bytes} @param response: A complete HTML document for an error page. @type location: L{bytes} @param location: The location response-header field value. It is an absolute URI used to redirect the receiver to a location other than the Request-URI so the request can be completed.  to Nrr$rr7r(rrr r7s rr$zPageRedirect.__init__us;4 tT7H5 <tj||||_yrS)rr$rT)r(rTs rr$zMissingTemplateLoader.__init__)sT7+ r)rcN|jjd|jdS)N: z had no loader)rXr.rTrJs rrYzMissingTemplateLoader.__repr__-s%..)),Bt||.>nMMr)NrZr5r)rrr!sN#Nr)rceZdZdZy)rzK Raised on any attempt to get a method which has not been exposed. NrMr5r)rrr1rNr)rceZdZdZy)r zL During flattening, a slot with no associated data was encountered. NrMr5r)rr r 7rNr)r ceZdZdZy)r z_ During flattening, an object of a type which cannot be flattened was encountered. NrMr5r)rr r =rPr)r ceZdZdZy)ExcessiveBufferingErrorz The HTTP/2 protocol has been forced to buffer an excessive amount of outbound data, and has therefore closed the connection and dropped all outbound data. NrMr5r)rrcrcDsr)rcc4eZdZdZdZdZdefdZdefdZy)r a  An error occurred while flattening an object. @ivar _roots: A list of the objects on the flattener's stack at the time the unflattenable object was encountered. The first element is least deeply nested object and the last element is the most deeply nested. c^||_||_||_tj ||||yrS) _exception_roots _tracebackr#r$)r( exceptionroots tracebacks rr$zFlattenerError.__init__Us+# #4E9=r)cddlm}t|ttfrEt |dkDr,t|trd}nd}t |dd|z|ddzSt |St||rO|jd |jzd zSd |j|j|j|jfzSt |S) a Convert an object from C{self._roots} to a string suitable for inclusion in a render-traceback (like a normal Python traceback, but can include "frame" source locations which are not in Python source files). @param obj: Any object which can be a render step I{root}. Typically, L{Tag}s, strings, and other simple Python types. @return: A string representation of C{obj}. @rtype: L{str} r )Tag(z<...>s<...>NizTag <>z&File "%s", line %d, column %d, in "%s") twisted.web.templatermr%r2r4r&asciifilenametagName lineNumber columnNumber)r(objrmellipsiss r _formatRootzFlattenerError._formatRoot[s - cE3< ( 3x"}c3'&H'HS"X03st9<==Sz! S !||#,s22?LLNN$$KK C: r)rc ddlm}|jr?ddj|jDcgc]}|j |c}zdz}nd}|j rJdj||j Dcgc]}|j D]}|c}}dz}nd}ttd|z|z|jjjzdzt|jzdzScc}wcc}}w) z Present a string representation which includes a template traceback, so we can tell where this error occurred in the template, as well as in Python. r ) format_listz z  zException while flattening: r^) rkr{rgjoinryrh splitlinesrr4rfrXr.)r(r{rrjentrylinerks rrYzFlattenerError.__repr__s" * ;;v{{#MAD$4$4Q$7#MNNQUU E ?? &1%A!$)$4$4$6! I ///++445  doo& '    #$Ns C? D ct|SrS)reprrJs rr-zFlattenerError.__str__s Dzr)N) r.r/r0r1r$ryr4rYr-r5r)rr r Ls+> *X) #) Vr)r ceZdZdZy)UnsupportedSpecialHeaderzz A HTTP/2 request was received that contained a HTTP/2 pseudo-header field that is not recognised by Twisted. NrMr5r)rrrrPr)rN)r1__all__collections.abcrtypingrrrtwisted.python.compatrtwisted.web._responsesrrr2rr#rrrr rDrLrrrrr r rcr rr5r)rrs  %((., sEz* x ;I;|&!5&!R#!%#!L!U!H: :@ ) + * NK N 9 9 iigYgTyr)