
    ϪfK                     F    d dl mZ  G d dej                        Zd Zd Zy)    )resourcec                   $    e Zd Zd Zd Zd Zd Zy)RewriterResourcec                 p    t         j                  j                  |        || _         t        |      | _        y N)r   Resource__init__listrewriteRules)selforigr   s      5/usr/lib/python3/dist-packages/twisted/web/rewrite.pyr	   zRewriterResource.__init__	   s*    ""4( .    c                 6    | j                   D ]
  } ||        y r   )r   )r   requestrewriteRules      r   _rewritezRewriterResource._rewrite   s    ,, 	!K 	!r   c                 4   |j                   j                  d|       |j                  j                          | j	                  |       |j                   j                  d      }|j                  j                  |       | j                  j                  ||      S )Nr   )postpathinsertprepathpopr   appendr   getChildWithDefault)r   pathr   s      r   getChildzRewriterResource.getChild   ss    4(g##A&t$}}00w??r   c                 Z    | j                  |       | j                  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      s    /
!@-r   r   c                     | j                   rh| j                   d   d d dk(  rRd| j                   d   dd  g| j                   d d ddj                  | j                  | j                   z         z   | _        y y y )Nr      ~users/)r   joinr   r   )r   s    r   tildeToUsersr)      sy    G,,Q/3s: ')9)9!)<QR)@A!SXXgoo8H8H&HII ;r   c                 Z     j                  d       j                  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(  rS| j                   t              d  }|z   | _         ddj                  | j                  | j                   z         z   | _        y y )Nr'   )r   lenr(   r   r   )r   after	aliasPath
sourcePaths     r   rewriterzalias.<locals>.rewriter1   sj    ,c)n-:$$S^%56E)E1G'//G<L<L*L!MMGL ;r   )split)r.   r/   r0   s   `` r   aliasr2   %   s0     !!#&J$IN Or   N)twisted.webr   r   r   r)   r2   r"   r   r   <module>r4      s'   
 !-x(( -.Jr   