
    h                    4    S SK Jr  S SKrSS1r " S S5      rg)    )annotationsN*$c                  @    \ rS rSrSrSS jrS	S jr\S
S j5       rSr	g)_URLPattern   z.Internal class which represents a URL pattern.c                n   Xl         [        U5      U l        SU R                   ;   U l        U R                   R	                  S5      U l        U R                  (       a.  U R                   S U R                   R                  S5       U l        O%U R
                  (       a  U R                   S S U l        S U l	        g )Nr   r   )
_patternlenpriority_contains_asteriskendswith_contains_dollarfind_pattern_before_asterisk_pattern_before_dollar_pattern_compiled)selfpatterns     Z/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/protego/_urlpattern.py__init___URLPattern.__init__   s    $ \(+t}}(<&*mm&<&<S&A""15)$--$$S)2D) ""/3}}Sb/AD'9=    c                   U R                   b$  [        U R                   R                  U5      5      $ U R                  (       d:  U R                  (       d  UR                  U R                  5      $ XR                  :H  $ UR                  U R                  5      (       d  gU R                  U R                  5      n[        R                  " U5      U l         [        U R                   R                  U5      5      $ )zEReturn True if pattern matches the given URL, otherwise return False.F)r   boolmatchr   r   
startswithr   r   r   _prepare_pattern_for_regexrecompile)r   url_pattern_regexs      r   r   _URLPattern.match   s     !!-..44S9::&&((~~dmm44 5555~~d;;<<88G!#N!;D**00566r   c                   [         R                  " SSU 5      n [         R                  " SU 5      n[        U5       H7  u  p#U[        ;  a  [         R
                  " U5      X'   M)  X   S:X  d  M3  SX'   M9     SR                  U5      $ )z:Return equivalent regex pattern for the given URL pattern.z\*+r   z(\*|\$$)z.*? )r    subsplit	enumerate
_WILDCARDSescapejoin)r   sindexsubstrs       r   r   &_URLPattern._prepare_pattern_for_regex/   sn     &&g.HH['*&q\MEZ'99V,S 	 *
 wwqzr   )r   r   r   r   r   r   r   N)r   str)r"   r1   returnr   )r   r1   r2   r1   )
__name__
__module____qualname____firstlineno____doc__r   r   staticmethodr   __static_attributes__ r   r   r   r      s#    8>7* 	 	r   r   )
__future__r   r    r*   r   r:   r   r   <module>r<      s    " 	3Z
1 1r   