%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/web/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/web/__pycache__/error.cpython-312.pyc

�

Ϫ�fV5���dZgd�ZddlmZddlmZmZmZddlm	Z	ddl
mZdeee
fdee
fd	�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd �d!e�ZGd"�d#e�ZGd$�d%e�ZGd&�d'e�Zy())z+
Exception definitions for L{twisted.web}.
)�Error�PageRedirect�InfiniteRedirection�RenderError�MissingRenderMethod�MissingTemplateLoader�UnexposedMethodError�UnfilledSlot�UnsupportedType�FlattenerError�RedirectWithNoLocation�)�Sequence)�Optional�Union�cast)�nativeString)�	RESPONSES�code�returnc�j�	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)r�get�int�
ValueError�AttributeError)rs �3/usr/lib/python3/dist-packages/twisted/web/error.py�_codeToMessagers1����}�}�S��Y�'�'����'����s� �2�2c	�|�eZdZUdZeed<eeed<eeed<		d
deeefdeedeeddfd�Z	de
fd	�Zy)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.
    �status�message�responseNrrc��|xst|�}tj||||�t|t�rd|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%d�zNot a valid HTTP status code: N)r�	Exception�__init__�
isinstancer�len�isdigitrrrr )�selfrrr s    rr$zError.__init__=s{��,�1�^�D�1�����4��w��9��d�C� ��D�7�?�D�
��Y�!�^�4�<�<�>��=�d�X�F�G�G������� ��
�c�l�|j}|jr|d|jzz
}t|�S)N� )rrr)r(�ss  r�__str__z
Error.__str__es/���K�K���<�<�
�����$�$�A��A��r))NN)�__name__�
__module__�__qualname__�__doc__�bytes�__annotations__rrrr$�strr-�r)rrr.ss���
�M�
�e�_���u�o��
$(�$(�	&!��C��J��&!��%��&!��5�/�	&!�

�&!�P��r)rc�b�eZdZUdZeeed<			d	deeefdeedeedeeddf
d�Z	y)
rz{
    A request resulted in an HTTP redirect.

    @ivar location: The location of the redirect which was not followed.
    �locationNrrr rc��tj||||�|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 N�rr$rr7�r(rrr r7s     rr$zPageRedirect.__init__us;��4	���t�T�7�H�5��<�<�H��<�<�'�1�H�<�D�L� ��
r)�NNN�
r.r/r0r1rr2r3rrr$r5r)rrrlsh����u�o��
$(�$(�$(�!��C��J��!��%��!��5�/�	!�
�5�/�!�
�
!r)rc�b�eZdZUdZeeed<			d	deeefdeedeedeeddf
d�Z	y)
rz�
    HTTP redirection is occurring endlessly.

    @ivar location: The first URL in the series of redirections which was
        not followed.
    r7Nrrr rc��tj||||�|jr|r|jdz|z|_||_y)at
        Initializes an infinite redirection exception.

        @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.

        @param message: A short error message, for example C{b"NOT FOUND"}.

        @param response: A complete HTML document for an error page.

        @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.
        r9Nr:r;s     rr$zInfiniteRedirection.__init__�s;��,	���t�T�7�H�5��<�<�H��<�<�'�1�H�<�D�L� ��
r)r<r=r5r)rrr�sh����u�o��
$(�$(�$(�!��C��J��!��%��!��5�/�	!�
�5�/�!�
�
!r)rc�H�eZdZUdZeed<eed<deeefdededdfd�Zy)rz�
    Exception passed to L{ResponseFailed} if we got a redirect without a
    C{Location} header field.

    @type uri: L{bytes}
    @ivar uri: The URI which failed to give a proper location header
        field.

    @since: 11.1
    r�urirrNc�n�tj|||�|jdz|z|_||_y)a
        Initializes a page redirect exception when no location is given.

        @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.

        @type uri: L{bytes}
        @param uri: The URI which failed to give a proper location header
            field.
        r9N)rr$rrA)r(rrrAs    rr$zRedirectWithNoLocation.__init__�s0�� 	���t�T�7�+��|�|�g�-��3�����r))	r.r/r0r1r2r3rrr$r5r)rrr�s=��	��N�	�J��U�5�#�:�.����U��t�r)rc�&�eZdZdZdZd�Zdefd�Zy)�UnsupportedMethoda^
    Raised by a resource when faced with a strange request method.

    RFC 2616 (HTTP 1.1) gives us two choices when faced with this situation:
    If the type of request is known to us, but not allowed for the requested
    resource, respond with NOT_ALLOWED.  Otherwise, if the request is something
    we don't know how to deal with in any case, respond with NOT_IMPLEMENTED.

    When this exception is raised by a Resource's render method, the server
    will make the appropriate response.

    This exception's first argument MUST be a sequence of the methods the
    resource *does* support.
    r5c�v�tj||g|���||_t|t�std��y)Nz`First argument must be a sequence of supported methods, but my first argument is not a sequence.)r#r$�allowedMethodsr%r�	TypeError)r(rF�argss   rr$zUnsupportedMethod.__init__�s@�����4��7�$�7�,����.�(�3��;��
�4r)rc� �d|j��S)NzExpected one of )rF�r(s rr-zUnsupportedMethod.__str__�s��!�$�"5�"5�!8�9�9r)N)r.r/r0r1rFr$r4r-r5r)rrDrD�s��
��N��:��:r)rDc��eZdZdZy)�SchemeNotSupportedzB
    The scheme of a URI was not one of the supported values.
    N�r.r/r0r1r5r)rrLrL����r)rLc��eZdZdZy)rz\
    Base exception class for all errors which can occur during template
    rendering.
    NrMr5r)rrr���r)rc�"�eZdZdZd�Zdefd�Zy)rz�
    Tried to use a render method which does not exist.

    @ivar element: The element which did not have the render method.
    @ivar renderName: The name of the renderer which could not be found.
    c�N�tj|||�||_||_y�N)rr$�element�
renderName)r(rTrUs   rr$zMissingRenderMethod.__init__s"�����T�7�J�7����$��r)rc�x�dj|jj|j|j�S)Nz*{!r}: {!r} had no render method named {!r})�format�	__class__r.rTrUrJs r�__repr__zMissingRenderMethod.__repr__s0��;�B�B��N�N�#�#��L�L��O�O�
�	
r)N�r.r/r0r1r$r4rYr5r)rrrs���%�

�#�
r)rc�"�eZdZdZd�Zdefd�Zy)rz�
    L{MissingTemplateLoader} is raised when trying to render an Element without
    a template loader, i.e. a C{loader} attribute.

    @ivar element: The Element which did not have a document factory.
    c�>�tj||�||_yrS)rr$rT)r(rTs  rr$zMissingTemplateLoader.__init__)s�����T�7�+���r)rc�N�|jj�d|j�d�S)N�: z had no loader)rXr.rTrJs rrYzMissingTemplateLoader.__repr__-s%���.�.�)�)�,�B�t�|�|�.>�n�M�Mr)NrZr5r)rrr!s����N�#�Nr)rc��eZdZdZy)rzK
    Raised on any attempt to get a method which has not been exposed.
    NrMr5r)rrr1rNr)rc��eZdZdZy)r	zL
    During flattening, a slot with no associated data was encountered.
    NrMr5r)rr	r	7rNr)r	c��eZdZdZy)r
z_
    During flattening, an object of a type which cannot be flattened was
    encountered.
    NrMr5r)rr
r
=rPr)r
c��eZdZdZy)�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)rrcrcDs��r)rcc�4�eZdZdZd�Zd�Zdefd�Zdefd�Zy)ra 
    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(�	exception�roots�	tracebacks    rr$zFlattenerError.__init__Us+��#������#������4��E�9�=r)c��ddlm}t|ttf�rEt|�dkDr,t|t�rd}nd}t
|dd|z|ddz�St
|�St||�rO|j�d	|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<...>N�i��zTag <�>z&File "%s", line %d, column %d, in "%s")�twisted.web.templatermr%r2r4r&�ascii�filename�tagName�
lineNumber�columnNumber)r(�objrm�ellipsiss    r�_formatRootzFlattenerError._formatRoot[s���	-��c�E�3�<�(��3�x�"�}��c�3�'�&�H�'�H��S��"�X��0�3�s�t�9�<�=�=��S�z�!�
��S�
!��|�|�#�����,�s�2�2�?��L�L��N�N��$�$��K�K�	C�����:�r)rc	��ddlm}|jr?ddj|jD�cgc]}|j	|���c}�zdz}nd}|j
rJdj||j
�D��cgc]}|j
�D]}|���c}}�dz}nd}ttd|z|z|jjjzdzt|j�zdz�Scc}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{rg�joinryrh�
splitlinesrr4rfrXr.)r(r{�rrj�entry�linerks       rrYzFlattenerError.__repr__�s"��	*��;�;��v�{�{����#M�A�D�$4�$4�Q�$7�#M�N�N�QU�U�
��E��?�?��	�	�&1����%A��!�$)�$4�$4�$6��!��������
��I���/������/�/�+�+�4�4�5��	�
�d�o�o�&�'��
�
�	
��#$N��s�C?
�D
c��t|�SrS)�reprrJs rr-zFlattenerError.__str__�s���D�z�r)N)	r.r/r0r1r$ryr4rYr-r5r)rrrLs+���>�*�X)
�#�)
�V��r)rc��eZdZdZy)�UnsupportedSpecialHeaderzz
    A HTTP/2 request was received that contained a HTTP/2 pseudo-header field
    that is not recognised by Twisted.
    NrMr5r)rr�r��rPr)r�N)r1�__all__�collections.abcr�typingrrr�twisted.python.compatr�twisted.web._responsesrrr2rr#rrrrrDrLrrrrr	r
rcrr�r5r)r�<module>r�s��
���%�(�(�.�,���s�E�z�*��x����;�I�;�|&!�5�&!�R#!�%�#!�L!�U�!�H:�	�:�@����)��
�+�
�*
N�K�
N� �9���9���i���i��g�Y�g�T�y�r)

Zerion Mini Shell 1.0