
    \dK                     D    d dl mZ  G d dej                  Zd Zd ZdS )    )resourcec                   &    e Zd Zd Zd Zd Zd ZdS )RewriterResourcec                 z    t           j                            |            || _         t          |          | _        d S N)r   Resource__init__listrewriteRules)selforigr   s      3lib/python3.11/site-packages/twisted/web/rewrite.pyr	   zRewriterResource.__init__	   s6    ""4((( ..    c                 0    | j         D ]} ||           d S r   )r   )r   requestrewriteRules      r   _rewritezRewriterResource._rewrite   s1    , 	! 	!KK    	! 	!r   c                 2   |j                             d|           |j                                         |                     |           |j                             d          }|j                            |           | j                            ||          S )Nr   )postpathinsertprepathpopr   appendr   getChildWithDefault)r   pathr   s      r   getChildzRewriterResource.getChild   s    4(((g##A&&t$$$}00w???r   c                 `    |                      |           | j                            |          S r   )r   r   render)r   r   s     r   r   zRewriterResource.render   s*    g}##G,,,r   N)__name__
__module____qualname__r	   r   r   r    r   r   r   r      sS        / / /
! ! !@ @ @- - - - -r   r   c                     | j         rf| j         d         d d         dk    rOd| j         d         dd          g| j         d d<   dd                    | j        | j         z             z   | _        d S d S d S )Nr      ~users/)r   joinr   r   )r   s    r   tildeToUsersr)      s     JG,Q/3s:: ')9!)<QRR)@A!SXXgo8H&HIIIJ J::r   c                 j                          d                                d            fd}|S )a  
    I am not a very good aliaser. But I'm the best I can be. If I'm
    aliasing to a Resource that generates links, and it uses any parts
    of request.prepath to do so, the links will not be relative to the
    aliased path, but rather to the aliased-to path. That I can't
    alias static.File directory listings that nicely. However, I can
    still be useful, as many resources will play nice.
    r'   c                     | j         d t                             k    rR| j         t                    d          }|z   | _         dd                    | j        | j         z             z   | _        d S d S )Nr'   )r   lenr(   r   r   )r   after	aliasPath
sourcePaths     r   rewriterzalias.<locals>.rewriter1   sv    ,c)nn,-::$S^^%5%56E)E1G'/G<L*L!M!MMGLLL ;:r   )split)r.   r/   r0   s   `` r   aliasr2   %   sU     !!#&&J$$IN N N N N N Or   N)twisted.webr   r   r   r)   r2   r"   r   r   <module>r4      sq   
 !          - - - - -x( - - -.J J J    r   