§
    ÈtºfŽ  ã                   óF  — d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZmZmZmZ dZ G d	„ d
e¦  «        Z G d„ d¦  «        Z ej        dde¦  «        Zd„ Zd„ Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        ZdS )zH
I contain PythonScript, which is a very simple python script resource.
é    N)ÚStringIO)Ú	copyright)ÚexecfileÚnetworkString)Ú_coerceToFilesystemEncoding)ÚhttpÚresourceÚserverÚstaticÚutilzº<p>You forgot to assign to the variable "resource" in your script. For example:</p>
<pre>
# MyCoolWebApp.rpy

import mygreatresource

resource = mygreatresource.MyGreatResource()
</pre>
c                   ó   — e Zd ZdZdS )ÚAlreadyCachedzG
    This exception is raised when a path has already been cached.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úQ/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/web/script.pyr   r      s   € € € € € ðð ð ð r   r   c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )ÚCacheScannerc                 ó0   — || _         || _        d| _        d S )Nr   )ÚpathÚregistryÚdoCache©Úselfr   r   s      r   Ú__init__zCacheScanner.__init__%   s   € ØˆŒ	Ø ˆŒØˆŒˆˆr   c                 óŽ   — | j                              | j        ¦  «        }|�t          |¦  «        ‚|                      ¦   «          d S ©N)r   ÚgetCachedPathr   r   Úrecache)r   Úcs     r   ÚcachezCacheScanner.cache*   s=   € ØŒM×'Ò'¨¬	Ñ2Ô2ˆØˆ=Ý Ñ"Ô"Ð"Ø�Š‰Œˆˆˆr   c                 ó   — d| _         d S )Né   )r   )r   s    r   r"   zCacheScanner.recache0   s   € ØˆŒˆˆr   N)r   r   r   r   r$   r"   r   r   r   r   r   $   sA   € € € € € ðð ð ð
ð ð ðð ð ð ð r   r   éô  úWhoops! Internal Errorc                 ó:  — t          | |¦  «        }t          d| ¦  «        t          ||j        |j        dœ}	 t          | ||¦  «         n$# t          $ r}|j        d         cY d}~S d}~ww xY w|d         }|j        r|t          ur| 	                    | |¦  «         |S )zª
    I am a normal py file which must define a 'resource' global, which should
    be an instance of (a subclass of) web.resource.Resource; it will be
    renderred.
    Ú )Ú__file__r	   r   r$   r"   r   Nr	   )
r   r   ÚnoRsrcr$   r"   r   r   Úargsr   Ú	cachePath)r   r   ÚcsÚglobÚacÚrsrcs         r   ÚResourceScriptr3   7   sÉ   € õ 
�d˜HÑ	%Ô	%€Bå/°°DÑ9Ô9ÝØØ”Ø”:ðð €DðÝ��t˜TÑ"Ô"Ð"Ð"øÝð ð ð ØŒw�qŒzÐÐÐÐÐÐøøøøðøøøà�
Ô€DØ	„zð '�d¥&Ð(Ð(Ø×Ò˜4 Ñ&Ô&Ð&Ø€Ks   ·A	 Á	
A*ÁA%ÁA*Á%A*c                 ó6  — ddl m} t          d| ¦  «        t          j        ddt
          ¦  «        |dœ}t          | ¦  «        5 }|                     || ¦  «        }d d d ¦  «         n# 1 swxY w Y   t          |dd¦  «        }t          |||¦  «         |d	         S )
Nr   )Úptl_compiler*   r'   r(   )r+   r	   r   z<source>Úexecr	   )
Úquixoter5   r   r	   Ú_UnsafeErrorPageÚrpyNoResourceÚopenÚcompile_templateÚcompileÚeval)r   r   r5   r0   ÚfÚeÚcodes          r   ÚResourceTemplaterA   O   sï   € Ø#Ð#Ð#Ð#Ð#Ð#õ 0°°DÑ9Ô9ÝÔ-ØÐ)­=ñ
ô 
ð ðð €Dõ 
ˆd‰Œð 2�qØ×(Ò(¨¨DÑ1Ô1ˆð2ð 2ð 2ñ 2ô 2ð 2ð 2ð 2ð 2ð 2ð 2øøøð 2ð 2ð 2ð 2å�1�j &Ñ)Ô)€DÝˆˆt�TÑÔÐØ�
ÔÐs   ÁA&Á&A*Á-A*c                   ó"   — e Zd Zdd„Zd„ Zd„ ZdS )ÚResourceScriptWrapperNc                 ó†   — t           j                             | ¦  «         || _        |pt	          j        ¦   «         | _        d S r    ©r	   ÚResourcer   r   r   ÚRegistryr   r   s      r   r   zResourceScriptWrapper.__init__b   s8   € ÝÔ×"Ò" 4Ñ(Ô(Ð(ØˆŒ	Ø Ð5¥F¤OÑ$5Ô$5ˆŒˆˆr   c                 ó`   — t          | j        | j        ¦  «        }|                     |¦  «        S r    )r3   r   r   Úrender)r   ÚrequestÚress      r   rI   zResourceScriptWrapper.renderg   s'   € Ý˜TœY¨¬Ñ6Ô6ˆØ�zŠz˜'Ñ"Ô"Ð"r   c                 ób   — t          | j        | j        ¦  «        }|                     ||¦  «        S r    )r3   r   r   ÚgetChildWithDefault)r   r   rJ   rK   s       r   rM   z)ResourceScriptWrapper.getChildWithDefaultk   s+   € Ý˜TœY¨¬Ñ6Ô6ˆØ×&Ò& t¨WÑ5Ô5Ð5r   r    )r   r   r   r   rI   rM   r   r   r   rC   rC   a   sF   € € € € € ð6ð 6ð 6ð 6ð
#ð #ð #ð6ð 6ð 6ð 6ð 6r   rC   c                   ó&   — e Zd ZdZdd„Zd„ Zd„ ZdS )ÚResourceScriptDirectorya  
    L{ResourceScriptDirectory} is a resource which serves scripts from a
    filesystem directory.  File children of a L{ResourceScriptDirectory} will
    be served using L{ResourceScript}.  Directory children will be served using
    another L{ResourceScriptDirectory}.

    @ivar path: A C{str} giving the filesystem path in which children will be
        looked up.

    @ivar registry: A L{static.Registry} instance which will be used to decide
        how to interpret scripts found as children of this resource.
    Nc                 ó†   — t           j                             | ¦  «         || _        |pt	          j        ¦   «         | _        d S r    rE   )r   Úpathnamer   s      r   r   z ResourceScriptDirectory.__init__~   s8   € ÝÔ×"Ò" 4Ñ(Ô(Ð(ØˆŒ	Ø Ð5¥F¤OÑ$5Ô$5ˆŒˆˆr   c                 óB  — t           j                             | j        |¦  «        }t           j                             |¦  «        rt	          || j        ¦  «        S t           j                             |¦  «        rt          || j        ¦  «        S t          j	        ¦   «         S r    )
Úosr   ÚjoinÚisdirrO   r   Úexistsr3   r	   Ú_UnsafeNoResource)r   r   rJ   Úfns       r   ÚgetChildz ResourceScriptDirectory.getChildƒ   sx   € ÝŒW�\Š\˜$œ) TÑ*Ô*ˆåŒ7�=Š=˜ÑÔð 	>Ý*¨2¨t¬}Ñ=Ô=Ð=ÝŒ7�>Š>˜"ÑÔð 	5Ý! " d¤mÑ4Ô4Ð4ÝÔ)Ñ+Ô+Ð+r   c                 óN   — t          j        ¦   «                              |¦  «        S r    )r	   rW   rI   )r   rJ   s     r   rI   zResourceScriptDirectory.renderŒ   s   € ÝÔ)Ñ+Ô+×2Ò2°7Ñ;Ô;Ð;r   r    )r   r   r   r   r   rY   rI   r   r   r   rO   rO   p   sP   € € € € € ðð ð6ð 6ð 6ð 6ð
,ð ,ð ,ð<ð <ð <ð <ð <r   rO   c                   ó"   — e Zd ZdZdZd„ Zd„ ZdS )ÚPythonScriptz¾
    I am an extremely simple dynamic resource; an embedded python script.

    This will execute a file (usually of the extension '.epy') as Python code,
    internal to the webserver.
    Tc                 ó"   — || _         || _        dS )z3
        Initialize me with a script name.
        N)Úfilenamer   )r   r^   r   s      r   r   zPythonScript.__init__š   s   € ð !ˆŒØ ˆŒˆˆr   c                 ó   — |                      dt          dt          j        z  ¦  «        ¦  «         |t	          d| j        ¦  «        | j        dœ}	 t          | j        ||¦  «         nù# t          $ rn}|j	        dk    rY| 
                    t          j        ¦  «         |                     t          j        d¦  «                             |¦  «        ¦  «         Y d}~n†d}~wt"          $ rv t%          ¦   «         }t'          j        |¬¦  «         t+          j        |                     ¦   «         ¦  «        }|                     d	¦  «        }|                     |¦  «         Y nw xY w|                     ¦   «          t4          j        S )
a4  
        Render me to a web client.

        Load my file, execute it in a special namespace (with 'request' and
        '__file__' global vars) and finish the request.  Output to the web-page
        will NOT be handled with print - standard output goes to the log - but
        with request.write.
        s   x-powered-byz
Twisted/%sr*   )rJ   r+   r   é   zFile not found.N)ÚfileÚutf8)Ú	setHeaderr   r   Úversionr   r^   r   r   ÚOSErrorÚerrnoÚsetResponseCoder   Ú	NOT_FOUNDÚwriter	   rW   rI   ÚBaseExceptionr   Ú	tracebackÚ	print_excr   Ú_PREÚgetvalueÚencodeÚfinishr
   ÚNOT_DONE_YET)r   rJ   Ú	namespacer?   ÚioÚoutputs         r   rI   zPythonScript.render¡   sv  € ð 	×ÒØ�]¨<½)Ô:KÑ+KÑLÔLñ	
ô 	
ð 	
ð Ý3°B¸¼ÑFÔFØœð
ð 
ˆ	ð
	"Ý�T”] I¨yÑ9Ô9Ð9Ð9øÝð 	ð 	ð 	ØŒw˜!Š|ˆ|Ø×'Ò'­¬Ñ7Ô7Ð7Ø—’ÝÔ.Ð/@ÑAÔA×HÒHÈÑQÔQñô ð øøøøøøøøøõ ð 	"ð 	"ð 	"Ý‘”ˆBÝÔ RÐ(Ñ(Ô(Ð(Ý”Y˜rŸ{š{™}œ}Ñ-Ô-ˆFØ—]’] 6Ñ*Ô*ˆFØ�MŠM˜&Ñ!Ô!Ð!Ð!Ð!ð	"øøøð 	�ŠÑÔÐÝÔ"Ð"s    ÁA' Á'
EÁ1A$CÃB EÅEN)r   r   r   r   ÚisLeafr   rI   r   r   r   r\   r\   �   sC   € € € € € ðð ð €Fð!ð !ð !ð #ð  #ð  #ð  #ð  #r   r\   )r   rS   rk   rs   r   Útwistedr   Útwisted.python.compatr   r   Útwisted.python.filepathr   Útwisted.webr   r	   r
   r   r   r9   Ú	Exceptionr   r   r8   r,   r3   rA   rF   rC   rO   r\   r   r   r   ú<module>r{      sÀ  ðð
ð ð
 
€	€	€	Ø Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <ð€ðð ð ð ð �Iñ ô ð ðð ð ð ð ñ ô ð ð  
#ˆÔ	" 3Ð(@À-Ñ	PÔ	P€ðð ð ð0ð ð ð$6ð 6ð 6ð 6ð 6˜HÔ-ñ 6ô 6ð 6ð<ð <ð <ð <ð <˜hÔ/ñ <ô <ð <ð@1#ð 1#ð 1#ð 1#ð 1#�8Ô$ñ 1#ô 1#ð 1#ð 1#ð 1#r   