-zddlmZmZmZddlmZ ddlmZddlm Z m Z e e_ e e_ dgZ GddeZGddeZGd d eZd S) )absolute_importdivisionunicode_literalsstr)urllib)parserequestRobotFileParsercJeZdZdZd dZdZdZdZdZdZ d Z d Z d Z d S)r zs This class provides a set of methods to read, parse and answer questions about a single robots.txt file. cvg|_d|_d|_d|_||d|_dS)NFr)entries default_entry disallow_all allow_allset_url last_checkedselfurls u/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/future/backports/urllib/robotparser.py__init__zRobotFileParser.__init__s@ !! Sc|jS)zReturns 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. )rrs rmtimezRobotFileParser.mtime&s   rc@ddl}||_dS)zYSets the time the robots.txt file was last fetched to the current time. rN)timer)rrs rmodifiedzRobotFileParser.modified/s#   IIKKrc|||_tj|dd\|_|_dS)z,Sets the URL referring to a robots.txt file.N)rrr urlparsehostpathrs rrzRobotFileParser.set_url7s4%|44S99!A#> 4999rc tj|j}|}||ddS#tjj $r:}|j dvrd|_ n|j dkr d|_ Yd}~dSYd}~dSYd}~dSd}~wwxYw)z4Reads the robots.txt URL and feeds it to the parser.zutf-8)iiTiN) rr urlopenrreadr decode splitlineserror HTTPErrorcoderr)rfrawerrs rr)zRobotFileParser.read<s 9&&tx00A&&((C JJszz'**5577 8 8 8 8 8|% & & &x:%%$(!!S!%!"!!!!! &s$A66C #B??Ccpd|jvr|j ||_dSdS|j|dSN*) useragentsrrappend)rentrys r _add_entryzRobotFileParser._add_entryIsM %" " "!)%*"""*) L   & & & & &rcRd}t}|D]}|sB|dkrt}d}n+|dkr%||t}d}|d}|dkr |d|}|}|s|dd}t |dkrH|d|d<tj |d|d<|ddkrM|dkr#||t}|j |dd}o|ddkr8|dkr0|j t|dd d}|dd kr6|dkr0|j t|dd d}|dkr||dSdS) zParse the input lines from a robots.txt file. We allow that a user-agent: line is not preceded by one or more blank lines. rr"#N:z user-agentdisallowFallowT)Entryr8findstripsplitlenlowerrr unquoter5r6 rulelinesRuleLine)rlinesstater7lineis rr zRobotFileParser.parseRs! "! "D A::!GGEEEaZZOOE***!GGEE #AAvvBQBx::< 4\**6<+?+?+D+DEE l%%r"Z_  j. 0C'EFFl  %% C\ , ,E ** ,s+++++ ,   5%//44 4trcJdd|jDS)Nr c2g|]}t|dzS) r).0r7s r z+RobotFileParser.__str__..s#DDDeE T)DDDr)joinrrs r__str__zRobotFileParser.__str__s%wwDDt|DDDEEErN)r ) __name__ __module__ __qualname____doc__rrr rr)r8r rWr^rrr r s !!!(((??? 9 9 9'''0#0#0#f.FFFFFrc$eZdZdZdZdZdZdS)rGzoA rule line is a single "Allow:" (allowance==True) or "Disallow:" (allowance==False) followed by a path.cp|dkr|sd}tj||_||_dS)Nr T)rr rRr&rT)rr&rTs rrzRuleLine.__init__s6 2::i:IL&&t,, "rcL|jdkp||jSr3)r& startswith)rfilenames rrSzRuleLine.applies_tos$yCA8#6#6ty#A#AArc.|jrdpddz|jzS)NAllowDisallowz: )rTr&rs rr^zRuleLine.__str__s *78jD@49LLrN)r_r`rarbrrSr^rcrrrGrGsS11###BBBMMMMMrrGc*eZdZdZdZdZdZdZdS)r?z?An entry has one or more user-agents and zero or more rulelinesc"g|_g|_dS)N)r5rFrs rrzEntry.__init__srcg}|jD]}|d|dg|jD]&}|t|dg'd|S)Nz User-agent: rZr )r5extendrFrr])rretagentrJs rr^z Entry.__str__su_ 6 6E JJt4 5 5 5 5N * *D JJD 4( ) ) ) )wws||rc|dd}|jD]&}|dkrdS|}||vrdS'dS)z2check if this entry applies to the specified agentrMrr4TF)rBrDr5)rrUrqs rrSzEntry.applies_tospOOC((+1133 _  E||ttKKMME !!tt"urcV|jD] }||r |jcS!dS)zZPreconditions: - our agent applies to this entry - filename is URL decodedT)rFrSrT)rrhrJs rrTzEntry.allowancesAN & &Dx(( &~%%% &trN)r_r`rarbrr^rSrTrcrrr?r?sVII   rr?N) __future__rrrfuture.builtinsrfuture.backportsrfuture.backports.urllibr _parser _request__all__objectr rGr?rcrrr|sBBBBBBBBBB $#####HHHHHHHH   EFEFEFEFEFfEFEFEFPMMMMMvMMM""""""F"""""r