Ë
    	š„jÑ  ã                   ó¦   — d dl mZmZmZ d dlmZ 	 d dlmZ d dlm	Z
mZ e
e_	        ee_        dgZ G d„ de«      Z G d„ de«      Z G d	„ d
e«      Zy)é    )Úabsolute_importÚdivisionÚunicode_literals)Ústr)Úurllib)ÚparseÚrequestÚRobotFileParserc                   óH   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zy)r
   zs This class provides a set of methods to read, parse and answer
    questions about a single robots.txt file.

    c                 ól   — g | _         d | _        d| _        d| _        | j	                  |«       d| _        y )NFr   )ÚentriesÚdefault_entryÚdisallow_allÚ	allow_allÚset_urlÚlast_checked©ÚselfÚurls     úZ/var/www/html/GAP/venv/lib/python3.12/site-packages/future/backports/urllib/robotparser.pyÚ__init__zRobotFileParser.__init__   s4   € ØˆŒØ!ˆÔØ!ˆÔØˆŒØ�‰�SÔØˆÕó    c                 ó   — | j                   S )z·Returns the time the robots.txt file was last fetched.

        This is useful for long-running web spiders that need to
        check for new robots.txt files periodically.

        )r   ©r   s    r   ÚmtimezRobotFileParser.mtime&   s   € ð × Ñ Ð r   c                 ó6   — ddl }|j                  «       | _        y)zYSets the time the robots.txt file was last fetched to the
        current time.

        r   N)Útimer   )r   r   s     r   ÚmodifiedzRobotFileParser.modified/   s   € ó
 	Ø ŸI™I›KˆÕr   c                 óp   — || _         t        j                  j                  |«      dd \  | _        | _        y)z,Sets the URL referring to a robots.txt file.é   é   N)r   r   r   ÚurlparseÚhostÚpathr   s     r   r   zRobotFileParser.set_url7   s-   € àˆŒÜ%Ÿ|™|×4Ñ4°SÓ9¸!¸AÐ>ÑˆŒ	�4•9r   c                 ó”  — 	 t         j                  j                  | j                  «      }|j	                  «       }| j                  |j                  d«      j                  «       «       y# t         j                  j                  $ r@}|j                  dv rd| _        n |j                  dk\  rd| _        Y d}~yY d}~yY d}~yd}~ww xY w)z4Reads the robots.txt URL and feeds it to the parser.zutf-8)i‘  i“  Ti�  N)r   r	   Úurlopenr   Úreadr   ÚdecodeÚ
splitlinesÚerrorÚ	HTTPErrorÚcoder   r   )r   ÚfÚrawÚerrs       r   r'   zRobotFileParser.read<   s˜   € ð		9Ü—‘×&Ñ& t§x¡xÓ0ˆAð —&‘&“(ˆCØ�J‰J�s—z‘z 'Ó*×5Ñ5Ó7Õ8øô �|‰|×%Ñ%ò 	&Ø�x‰x˜:Ñ%Ø$(�Õ!Ø—‘˜S’Ø!%�—‘ô !ô "ûð	&ús   ‚)A* Á*CÂ,CÃCc                 ó€   — d|j                   v r| j                  €|| _        y y | j                  j                  |«       y ©NÚ*)Ú
useragentsr   r   Úappend©r   Úentrys     r   Ú
_add_entryzRobotFileParser._add_entryI   s=   € Ø�%×"Ñ"Ñ"à×!Ñ!Ð)à%*�Õ"ð *ð �L‰L×Ñ Õ&r   c                 ó”  — d}t        «       }|D �]Ÿ  }|s4|dk(  rt        «       }d}n"|dk(  r| j                  |«       t        «       }d}|j                  d«      }|dk\  r|d| }|j                  «       }|sŒh|j	                  dd«      }t        |«      dk(  sŒ‰|d   j                  «       j                  «       |d<   t        j                  j                  |d   j                  «       «      |d<   |d   dk(  rB|dk(  r| j                  |«       t        «       }|j                  j                  |d   «       d}�Œ*|d   dk(  r3|dk7  s�Œ9|j                  j                  t        |d   d	«      «       d}�Œe|d   d
k(  s�Œo|dk7  s�Œv|j                  j                  t        |d   d«      «       d}�Œ¢ |dk(  r| j                  |«       yy)z”Parse the input lines from a robots.txt file.

        We allow that a user-agent: line is not preceded by
        one or more blank lines.
        r   r    é   ú#Nú:z
user-agentÚdisallowFÚallowT)ÚEntryr7   ÚfindÚstripÚsplitÚlenÚlowerr   r   Úunquoter3   r4   Ú	rulelinesÚRuleLine)r   ÚlinesÚstater6   ÚlineÚis         r   r   zRobotFileParser.parseR   s¦  € ð ˆÜ“ˆàó !	"ˆDÙØ˜A’:Ü!›G�EØ‘EØ˜a’ZØ—O‘O EÔ*Ü!›G�EØ�Eà—	‘	˜#“ˆAØ�AŠvØ˜B˜Q�x�Ø—:‘:“<ˆDÙØØ—:‘:˜c 1Ó%ˆDÜ�4‹y˜A‹~Ø˜q™'Ÿ-™-›/×/Ñ/Ó1��Q‘Ü Ÿ,™,×.Ñ.¨t°A©w¯}©}«Ó?��Q‘Ø˜‘7˜lÒ*Ø ’zØŸ™¨Ô.Ü %£˜Ø×$Ñ$×+Ñ+¨D°©GÔ4Ø’EØ˜!‘W 
Ò*Ø ”zØŸ™×.Ñ.¬x¸¸Q¹ÀÓ/GÔHØ !šØ˜!‘W Ô'Ø ”zØŸ™×.Ñ.¬x¸¸Q¹ÀÓ/FÔGØ !šðC!	"ðD �AŠ:Ø�O‰O˜EÕ"ð r   c                 óH  — | j                   ry| j                  ryt        j                  j	                  t        j                  j                  |«      «      }t        j                  j                  dd|j                  |j                  |j                  |j                  f«      }t        j                  j                  |«      }|sd}| j                  D ]&  }|j                  |«      sŒ|j                  |«      c S  | j                  r| j                  j                  |«      S y)z=using the parsed robots.txt decide if useragent can fetch urlFTÚ ú/)r   r   r   r   r"   rD   Ú
urlunparser$   ÚparamsÚqueryÚfragmentÚquoter   Ú
applies_toÚ	allowancer   )r   Ú	useragentr   Ú
parsed_urlr6   s        r   Ú	can_fetchzRobotFileParser.can_fetch…   sì   € à×ÒØØ�>Š>Øô —\‘\×*Ñ*¬6¯<©<×+?Ñ+?ÀÓ+DÓEˆ
Ü�l‰l×%Ñ% r¨"¨Z¯_©_Ø×Ñ˜j×.Ñ.°
×0CÑ0Cð'Eó Fˆä�l‰l× Ñ  Ó%ˆÙØˆCØ—\‘\ò 	,ˆEØ×Ñ 	Õ*Ø—‘ sÓ+Ò+ð	,ð ×ÒØ×%Ñ%×/Ñ/°Ó4Ð4àr   c                 óv   — dj                  | j                  D �cg c]  }t        |«      dz   ‘Œ c}«      S c c}w )NrL   ú
)Újoinr   r   r5   s     r   Ú__str__zRobotFileParser.__str__œ   s,   € Ø�w‰w°t·|±|ÖD¨eœ˜E›
 TÓ)ÒDÓEÐEùÒDs   š6N)rL   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r'   r7   r   rW   r[   © r   r   r
   r
      s6   „ ñó
ò!ò(ò?ò
9ò'ò0#òfó.Fr   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)rF   zoA rule line is a single "Allow:" (allowance==True) or "Disallow:"
       (allowance==False) followed by a path.c                 ól   — |dk(  r|sd}t         j                  j                  |«      | _        || _        y )NrL   T)r   r   rR   r$   rT   )r   r$   rT   s      r   r   zRuleLine.__init__£   s-   € Ø�2Š:™iàˆIÜ—L‘L×&Ñ& tÓ,ˆŒ	Ø"ˆ�r   c                 óZ   — | j                   dk(  xs |j                  | j                   «      S r1   )r$   Ú
startswith)r   Úfilenames     r   rS   zRuleLine.applies_toª   s%   € Ø�y‰y˜CÑÒA 8×#6Ñ#6°t·y±yÓ#AÐAr   c                 óJ   — | j                   xr dxs ddz   | j                  z   S )NÚAllowÚDisallowz: )rT   r$   r   s    r   r[   zRuleLine.__str__­   s$   € Ø—‘Ò* 7Ò8¨j¸DÑ@À4Ç9Á9ÑLÐLr   N)r\   r]   r^   r_   r   rS   r[   r`   r   r   rF   rF       s   „ ñ1ò#òBóMr   rF   c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)r>   z?An entry has one or more user-agents and zero or more rulelinesc                 ó    — g | _         g | _        y )N)r3   rE   r   s    r   r   zEntry.__init__³   s   € ØˆŒØˆ�r   c                 óÌ   — g }| j                   D ]  }|j                  d|dg«       Œ | j                  D ]  }|j                  t        |«      dg«       Œ  dj	                  |«      S )NzUser-agent: rY   rL   )r3   ÚextendrE   r   rZ   )r   ÚretÚagentrI   s       r   r[   zEntry.__str__·   sc   € ØˆØ—_‘_ò 	6ˆEØ�J‰J˜¨¨tÐ4Õ5ð	6à—N‘Nò 	*ˆDØ�J‰Jœ˜D›	 4Ð(Õ)ð	*à�w‰w�s‹|Ðr   c                 ó¤   — |j                  d«      d   j                  «       }| j                  D ]  }|dk(  r y|j                  «       }||v sŒ y y)z2check if this entry applies to the specified agentrM   r   r2   TF)rA   rC   r3   )r   rU   rn   s      r   rS   zEntry.applies_to¿   sX   € ð —O‘O CÓ(¨Ñ+×1Ñ1Ó3ˆ	Ø—_‘_ò 	ˆEØ˜Š|áØ—K‘K“MˆEØ˜	Ò!Ùð	ð r   c                 ód   — | j                   D ]!  }|j                  |«      sŒ|j                  c S  y)zZPreconditions:
        - our agent applies to this entry
        - filename is URL decodedT)rE   rS   rT   )r   re   rI   s      r   rT   zEntry.allowanceÌ   s2   € ð —N‘Nò 	&ˆDØ�‰˜xÕ(Ø—~‘~Ò%ð	&ð r   N)r\   r]   r^   r_   r   r[   rS   rT   r`   r   r   r>   r>   ±   s   „ ÙIòòòór   r>   N)Ú
__future__r   r   r   Úfuture.builtinsr   Úfuture.backportsr   Úfuture.backports.urllibr   Ú_parser	   Ú_requestÚ__all__Úobjectr
   rF   r>   r`   r   r   ú<module>ry      s^   ðß BÑ BÝ ð
õ $ß HØ€„Ø€„ð Ð
€ôEF�fô EFôPMˆvô Mô""ˆFõ "r   