%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__/tap.cpython-312.pyc

�

Ϫ�f(����dZddlZddlZddlZddlmZmZddlmZm	Z	ddl
mZmZm
Z
mZddlmZddlmZmZmZmZmZmZmZmZGd�d	ej4�Zd
�ZGd�dej8�Zd
�Zy)z9
Support for creating a service which runs a web server.
�N)�service�strports)�
interfaces�reactor)�	deprecate�reflect�
threadpool�usage)�pb)�demo�distrib�resource�script�server�static�twcgi�wsgic��eZdZdZdZgd�gd�gd�gZgd�gd�gZejdd	d
ejj�d�dzg�ejejd
�ejd�ejd�d���ZdZd�Zd�ZeZd�Zd�Zd�ZeZd�ZeZd�Zd�Zd�Zd�Zd�Zd�ZeZd�Z d�Z!d �Z"d!�Z#y")#�OptionszB
    Define the options accepted by the I{twistd web} plugin.
    z
[web options])�logfile�lNz/Path to web CLF (Combined Log Format) log file.)�certificate�c�
server.pemz=(DEPRECATED: use --listen) SSL certificate to use for HTTPS. )�privkey�krz<(DEPRECATED: use --listen) SSL certificate to use for HTTPS.)�notracebacks�nzY(DEPRECATED: Tracebacks are disabled by default. See --enable-tracebacks to turn them on.)�display-tracebacks�z�Show uncaught exceptions during rendering tracebacks to the client. WARNING: This may be a security risk and expose private data!�personalr zsInstead of generating a webserver, generate a ResourcePublisher which listens on  the port given by --listen, or ~/� zif --listen is not specified.z*.logz*.pem)rrr)�
optActionsz�This starts a webserver.  If you specify no arguments, it will be a
demo webserver that has the Test class from twisted.web.demo in it.c�~�tjj|�g|d<d|d<g|d<g|d<dx|d<|d<y)N�indexes�root�extraHeaders�ports�port�https)r
r�__init__��selfs �1/usr/lib/python3/dist-packages/twisted/web/tap.pyr+zOptions.__init__XsK��
�
�
���t�$���Y����V��!��^����W�
�'+�+��V��t�G�}�c	��tj|jtjdddd��}tj|td��||d<y)	zh
        (DEPRECATED: use --listen)
        Strports description of port to start the server on
        �Twisted��r���category�
stacklevelr)N)r�getDeprecationWarningString�opt_port�incremental�Version�warnings�warn�DeprecationWarning�r-r)�msgs   r.r9zOptions.opt_port`sJ��
�3�3��M�M�;�.�.�y�"�a��C�
��	�
�
�c�$6�1�E���V�r/c	��tj|jtjdddd��}tj|td��||d<y)	zW
        (DEPRECATED: use --listen)
        Port to listen on for Secure HTTP.
        r1r2r3rr4r5r*N)rr8�	opt_httpsr:r;r<r=r>r?s   r.rBzOptions.opt_httpsmsJ��
�3�3��N�N�K�/�/�	�2�q�!�D�
��	�
�
�c�$6�1�E���W�
r/c�,�|dj|�y)zi
        Add an strports description of port to start the server on.
        [default: tcp:8080]
        r(N��append)r-r)s  r.�
opt_listenzOptions.opt_listenxs��
	
�W�
���T�"r/c�,�|dj|�y)zr
        Add the name of a file used to check for directory indexes.
        [default: index, index.html]
        r%NrD)r-�	indexNames  r.�	opt_indexzOptions.opt_indexs��
	
�Y����y�)r/c�2�tj�|d<y)zc
        Makes a server with ~/public_html and ~/.twistd-web-pb support for
        users.
        r&N)r
�
UserDirectoryr,s r.�opt_userzOptions.opt_user�s��
�,�,�.��V�r/c��tjtjj	|��|d<t
jt
jd�|d_tj|djd<y)z�
        <path> is either a specific file or a directory to be set as the root
        of the web server. Use this if you have a directory full of HTML, cgi,
        epy, or rpy files or any other files that you want to be served up raw.
        r&)z.epyz.rpyz.cgiN)r�File�os�path�abspathr�PythonScript�ResourceScript�
processorsr�	CGIScript)r-rPs  r.�opt_pathzOptions.opt_path�s]���{�{�2�7�7�?�?�4�#8�9��V���'�'��)�)�#
��V���+0�/�/��V�����'r/c���t|dtj�stjd��|jdd�\}}t
j|�|dj|<y)zh
        `ext=class' where `class' is added as a Processor for files ending
        with `ext'.
        r&z*You can only use --processor after --path.�=�N)	�
isinstancerrNr
�
UsageError�splitr�
namedClassrT)r-�proc�ext�klasss    r.�
opt_processorzOptions.opt_processor�s[��
�$�v�,����4��"�"�#O�P�P��Z�Z��Q�'�
��U�'.�'9�'9�%�'@��V�����$r/c�B�tj|�}|�|d<y)zN
        Create a Resource subclass with a zero-argument constructor.
        r&N)rr])r-�	className�classObjs   r.�	opt_classzOptions.opt_class�s���%�%�i�0���z��V�r/c�4�tj|�|d<y)zP
        An .rpy file to be used as the root resource of the webserver.
        r&N)r�ResourceScriptWrapper)r-�names  r.�opt_resource_scriptzOptions.opt_resource_script�s���3�3�D�9��V�r/c�j�	tj|�}t
j�}tj|j�tjdd|j�tjt||�|d<y#ttf$rt	j
d|����wxYw)zo
        The FQPN of a WSGI application object to serve as the root resource of
        the webserver.
        zNo such WSGI application: �after�shutdownr&N)r�namedAny�AttributeError�
ValueErrorr
r[r	�
ThreadPoolr�callWhenRunning�start�addSystemEventTrigger�stopr�WSGIResource)r-rh�application�pools    r.�opt_wsgizOptions.opt_wsgi�s���
	J�!�*�*�4�0�K��$�$�&������
�
�+��%�%�g�z�4�9�9�E��(�(��$��D��V����
�+�	J��"�"�%?��x�#H�I�I�	J�s�B
�
(B2c�|�t|dtj�stjd��||d_y)zA
        Specify the default mime-type for static files.
        r&z*You can only use --mime_type after --path.N)rZrrNr
r[�defaultType)r-rzs  r.�
opt_mime_typezOptions.opt_mime_type�s4���$�v�,����4��"�"�#O�P�P�#.��V�� r/c��t|dtj�stjd��|djd�y)zT
        Specify whether or not a request for 'foo' should return 'foo.ext'
        r&z1You can only use --allow_ignore_ext after --path.�*N�rZrrNr
r[�	ignoreExtr,s r.�opt_allow_ignore_extzOptions.opt_allow_ignore_ext�s@���$�v�,����4��"�"�F��
�	
�V����s�#r/c��t|dtj�stjd��|dj|�y)zT
        Specify an extension to ignore.  These will be processed in order.
        r&z+You can only use --ignore_ext after --path.Nr~)r-r_s  r.�opt_ignore_extzOptions.opt_ignore_ext�s:���$�v�,����4��"�"�#S�T�T��V����s�#r/c��|jdd�\}}|dj|j�|j�f�y)z
        Specify an additional header to be included in all responses. Specified
        as "HeaderName: HeaderValue".
        �:rYr'N)r\rE�strip)r-�headerrh�values    r.�opt_add_headerzOptions.opt_add_header�s<��
�l�l�3��*���e��^��#�#�T�Z�Z�\�5�;�;�=�$A�Br/c�F�|d�|dj|d�|d�F	tjd�dj
|d|d|d	�}|dj|�t|d�d
k(r�|drmtjjtjjdtjj��}|djd
|z�y|djd�yy#t$rt	j
d��wxYw)a@
        Set up conditional defaults and check for dependencies.

        If SSL is not available but an HTTPS server was configured, raise a
        L{UsageError} indicating that this is not possible.

        If no server port was supplied, select a default appropriate for the
        other options supplied.
        r)Nr(r*zOpenSSL.SSLzSSL support not installedz$ssl:port={}:privateKey={}:certKey={}rrrr!�~zunix:ztcp:8080)rEr�namedModule�ImportErrorr
r[�format�lenrOrP�
expanduser�joinr
rK�userSocketName)r-�
sslStrportrPs   r.�postOptionszOptions.postOptions�s����<�#���M� � ��f��.���=�$�
D��#�#�M�2�@�F�F��W�
��Y���]�#��J�

��M� � ��,��t�G�}���"��J���w�w�)�)��G�G�L�L��g�&;�&;�&J�&J�K����W�
�$�$�W�t�^�4��W�
�$�$�Z�0�#���
D��&�&�'B�C�C�
D�s�D�D N)$�__name__�
__module__�__qualname__�__doc__�synopsis�
optParameters�optFlagsrEr
rKr�r
�Completions�
CompleteFiles�compData�longdescr+r9�opt_prBrFrI�opt_irL�opt_urVrarerirxr{�opt_mr�r�r�r��r/r.rrs0����H�	R�	
�	
��M�"	
�	
��H�(
�O�O���%,�$9�$9�$H�$H�
K�.�
.�	
�	�!�u� � �*�u�*�*�7�3�.�5�.�.�w�7�*�u�*�*�7�3�
��H�G�H�,�	�
�E�	�#�*�
�E�/�
�E�:�A�"�:�E�/�
�E�$�$�C�1r/rc�R�tjtj|��S)z�
    Create and return a factory which will respond to I{distrib} requests
    against the given site.

    @type site: L{twisted.web.server.Site}
    @rtype: L{twisted.internet.protocol.Factory}
    )r�PBServerFactoryr
�ResourcePublisher)�sites r.�makePersonalServerFactoryr�s �����g�7�7��=�>�>r/c��eZdZd�Zd�Zy)�_AddHeadersResourcec� �||_||_y�N)�_originalResource�_headers)r-�originalResource�headerss   r.r+z_AddHeadersResource.__init__s��!1�����
r/c��|jD]!\}}|jj||��#|jj	||�Sr�)r��responseHeaders�addRawHeaderr��getChildWithDefault)r-rh�requestr�vs     r.r�z'_AddHeadersResource.getChildWithDefaultsH���M�M�	7�D�A�q��#�#�0�0��A�6�	7��%�%�9�9�$��H�Hr/N)r�r�r�r+r�r�r/r.r�r�s
�� �Ir/r�c	���tj�}|dr|d}|dr"|d|d_ntj�}t|tj�r*|jjtj|�|drt||d�}|drtj||d��}ntj|�}|drd|_|drHt!j"d	t%j&d
ddd
��}t)j*|t,d��|drt/|�}|dD])}t1j||�}|j3|��+|S)Nr&r%r'r)�logPathrTrz--notracebacksr1��rr4r5r!r()r�MultiService�
indexNamesr�TestrZrrN�registry�setComponentr�IServiceCollectionr�r�Site�displayTracebacksr�_getDeprecationWarningStringr:r;r<r=r>r�r�setServiceParent)�config�sr&r�r@r)�svcs       r.�makeServicer�sR������A�
�f�~��f�~���)��(.�y�(9�F�6�N�%��y�y�{���$����$��
�
�"�"�:�#@�#@�!�D�
�n��"�4���)?�@��
�i���{�{�4��	�):�;���{�{�4� ��
�"�#�!%����n���4�4��k�1�1�)�R��A�F�
��	�
�
�c�$6�1�E�
�j��(��.���w�� �����t�T�*�����Q�� �
�Hr/)r�rOr<r:�twisted.applicationrr�twisted.internetrr�twisted.pythonrrr	r
�twisted.spreadr�twisted.webrr
rrrrrrrr��Resourcer�r�r�r/r.�<module>r�s^��
�

���1�0�@�@��T�T�T�o1�e�m�m�o1�d?�I�(�+�+�I�$
r/

Zerion Mini Shell 1.0