Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/urllib/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`s�ddlmZmZmZddlmZddlmZddlm Z
mZe
e_ ee_dgZ
defd��YZdefd ��YZd
efd��YZdS(
i(tabsolute_importtdivisiontunicode_literals(tstr(turllib(tparsetrequestuRobotFileParsertRobotFileParsercB`sbeZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z
d
�ZRS(us This class provides a set of methods to read, parse and answer
questions about a single robots.txt file.
ucC`s>g|_d|_t|_t|_|j|�d|_dS(Ni(tentriestNonet
default_entrytFalsetdisallow_allt allow_alltset_urltlast_checked(tselfturl((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyt__init__s
cC`s|jS(u�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((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pytmtime&scC`sddl}|j�|_dS(uYSets
the time the robots.txt file was last fetched to the
current time.
iN(ttimeR(RR((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pytmodified/scC`s2||_tjj|�dd!\|_|_dS(u,Sets
the URL referring to a robots.txt
file.iiN(RRRturlparsethosttpath(RR((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR7s cC`s�ytjj|j�}WnOtjjk
rj}|jdkrLt|_q�|jdkr�t|_ q�n)X|j
�}|j|jd�j
��dS(u4Reads the robots.txt URL and feeds it to
the
parser.i�i�i�uutf-8N(i�i�(RRturlopenRterrort HTTPErrortcodetTrueRR
treadRtdecodet
splitlines(Rtfterrtraw((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR<scC`sAd|jkr-|jdkr=||_q=n|jj|�dS(Nu*(t
useragentsR
R Rtappend(Rtentry((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyt
_add_entryIscC`sd}t�}x�|D]�}|sn|dkr@t�}d}qn|dkrn|j|�t�}d}qnn|jd�}|dkr�||
}n|j�}|s�qn|jdd�}t|�dkr|dj�j�|d<tjj |dj��|d<|ddkr^|dkrA|j|�t�}n|j
j|d�d}q�|ddkr�|dkr�|jjt
|dt��d}q�q�|ddkr�|dkr�|jjt
|dt��d}q�q�qqW|dkr|j|�nd S(
u�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.
iiiu#u:u
user-agentudisallowuallowN(tEntryR'tfindtstriptsplittlentlowerRRtunquoteR$R%t rulelinestRuleLineRR(RtlineststateR&tlineti((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyRRsJ
cC`s�|jr
tS|jrtStjjtjj|��}tjjdd|j |j
|j|jf�}tjj
|�}|s�d}nx-|jD]"}|j|�r�|j|�Sq�W|jr�|jj|�StS(u=using
the parsed robots.txt decide if useragent can fetch
urluu/(RRR
RRRRR.t
urlunparseRtparamstquerytfragmenttquoteRt
applies_tot allowanceR
(Rt useragentRt
parsed_urlR&((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyt can_fetch�s
cC`s-djg|jD]}t|�d^q�S(Nuu
(tjoinRR(RR&((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyt__str__�s(t__name__t
__module__t__doc__RRRRRR'RR>R@(((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyRs
3 R0cB`s)eZdZd�Zd�Zd�ZRS(uoA
rule line is a single "Allow:" (allowance==True) or
"Disallow:"
(allowance==False) followed by a
path.cC`s>|dkr|rt}ntjj|�|_||_dS(Nu(RRRR9RR;(RRR;((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR�s cC`s|jdkp|j|j�S(Nu*(Rt
startswith(Rtfilename((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR:�scC`s|jrdpdd|jS(NuAllowuDisallowu:
(R;R(R((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR@�s(RARBRCRR:R@(((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR0�s R(cB`s2eZdZd�Zd�Zd�Zd�ZRS(u?An
entry has one or more user-agents and zero or more
rulelinescC`sg|_g|_dS(N(R$R/(R((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR�s cC`sjg}x'|jD]}|jd|dg�qWx*|jD]}|jt|�dg�q:Wdj|�S(NuUser-agent:
u
u(R$textendR/RR?(RtrettagentR3((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR@�scC`s]|jd�dj�}x=|jD]2}|dkr9tS|j�}||kr#tSq#WtS(u2check
if this entry applies to the specified
agentu/iu*(R+R-R$RR(RR<RH((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR:�scC`s.x'|jD]}|j|�r
|jSq
WtS(uZPreconditions:
- our agent applies to this entry
- filename is URL
decoded(R/R:R;R(RRER3((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR;�s(RARBRCRR@R:R;(((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyR(�s
N(t
__future__RRRtfuture.builtinsRtfuture.backportsRtfuture.backports.urllibRt_parseRt_requestt__all__tobjectRR0R((((sG/usr/lib/python2.7/site-packages/future/backports/urllib/robotparser.pyt<module>s �