ó 1Tc@skdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZddlmZmZmZmZmZmZdd lmZd e fd „ƒYZe eƒZdge_de fd„ƒYZ defd„ƒYZ!d„Z"defd„ƒYZ#dS(sÙ sphinx.builders.linkcheck ~~~~~~~~~~~~~~~~~~~~~~~~~ The CheckExternalLinksBuilder class. :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. iÿÿÿÿN(tpath(t build_openertunquotetRequestt HTTPErrortHTTPRedirectHandler(t HTMLParsertHTMLParseError(tnodes(tBuilder(tpurpletredt darkgreentdarkgraytdarkredt turquoise(t TextIOWrappertRedirectHandlercBseZdZd„ZRS(s8A RedirectHandler that records the redirect code we got.cCs.tj|||||||ƒ}||_|S(N(Rtredirect_requestt redirect_code(tselftreqtfptcodetmsgtheaderstnewurltnew_req((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyR!s (t__name__t __module__t__doc__R(((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyRss User-agentsDMozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0t HeadRequestcBseZdZd„ZRS(s6Subclass of urllib2.Request that sends a HEAD request.cCsdS(NtHEAD((R((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyt get_method/s(RRRR!(((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyR-stAnchorCheckParsercBs eZdZd„Zd„ZRS(s9Specialized HTML parser that looks for a specific anchor.cCs#tj|ƒ||_t|_dS(N(Rt__init__t search_anchortFalsetfound(RR$((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyR#6s  cCsBx;|D]3\}}|dkr||jkrt|_qqWdS(Ntidtname(sidsname(R$tTrueR&(Rttagtattrstkeytvalue((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pythandle_starttag<s(RRRR#R.(((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyR"3s cCswt|ƒ}yP|jdƒ}x0|rP|j rP|j|ƒ|jdƒ}q!W|jƒWntk ronX|jS(sƒReads HTML data from a filelike object 'f' searching for anchor 'hash'. Returns True if anchor was found, False otherwise. i (R"treadR&tfeedtcloseR(tfthashtparsertchunk((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyt check_anchorBs   tCheckExternalLinksBuildercBsheZdZdZd„Zd„Zd„Zd d„Zd„Z d„Z d„Z d „Z d „Z RS( s+ Checks for broken external links. t linkcheckcCsòttj|jjjƒ|_tƒ|_i|_ i|_ t j dƒt tj|jdƒdƒjƒtjƒ|_tjƒ|_g|_xYt|jjjƒD]B}tjd|jƒ}|jtƒ|jƒ|jj|ƒq¨WdS(Ng@s output.txttwttarget(tmaptretcompiletapptconfigtlinkcheck_ignoret to_ignoretsettgoodtbrokent redirectedtsockettsetdefaulttimeouttopenRtjointoutdirR1tQueuetwqueuetrqueuetworkerstrangetlinkcheck_workerst threadingtThreadt check_threadt setDaemonR)tstarttappend(Rtitthread((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytinit\s    "   cs¼i‰tjdkr:ˆjjjr:ˆjjjˆdR?tlinkcheck_anchorsRtopenerRHthasattrRRaR6RRR1t ExceptionRRRtstrturltrstriptaddtgetattr( trextreq_urlR3RR2tencodingR&terrtnew_urlR(tkwargsRturi(sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytcheckusf"&&#     ! (ii( tsyst version_infoR>R?tlinkcheck_timeoutR)RLtgetRgRMtput(RRxtdocnametlinenotstatustinfoR((RvRRwsC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyRSpsC  c Cs*|\}}}}}}|dkr(dS|dkrD|dkrDdS|rd|jd|ddƒn|dkrŠ|jtdƒ|ƒnœ|d krÆ|jtd ƒ|ƒ|jd |||ƒn`|dkrì|jtd ƒ|ƒn:|d krw|jtd ƒ|td|ƒƒ|jd |||d|ƒ|jjr&|jd|d|jj |ƒ|fƒq&n¯|dkr&idt fd6dt fd6dt fd6dt fd6dt fd6|\}} |jd||||d|ƒ|j| dƒ|| d|d|ƒƒndS( NR\R_Rcs (line %4d) tnonliR`s -ignored- R^s -local- s ok RDs broken s - s: sbroken link: %ss%s:%sREt permanentlyi-s with Foundi.swith See Otheri/t temporarilyi3swith unknown codeis redirected s to s redirect ( RR t write_entryR R R>tquiettwarntenvtdoc2pathRR R( RtresultRwR~RR€RRttexttcolor((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytprocess_result¿s>     %  #       cCsdS(NR]((RR~ttyp((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytget_target_uriàscCs |jjS(N(Rˆt found_docs(R((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytget_outdated_docsãscCsdS(N((Rtdocnames((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytprepare_writingæscCsÿ|jƒd}x—|jtjƒD]ƒ}d|kr;q#n|d}d}x2|dkr|j}|dkrsPn|j}qNW|jj|||ft ƒ|d7}q#Wd}x0||krâ|j |j j ƒƒ|d7}q³W|j rûd|j_ndS(Nitrefurii(RttraverseRt referenceRgtparenttlineRLR}R%RRMR|RDR>t statuscode(RR~tdoctreetntnodeRwRtdone((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyt write_docés(       cCsXttj|jdƒdƒ}|jd|jj|dƒ|||fƒ|jƒdS(Ns output.txttas%s:%s: [%s] %s ( RHRRIRJtwriteRˆR‰RgR1(RtwhatR~R˜Rwtoutput((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyR…scCs+x$|jD]}|jjdtƒq WdS(N(NNN(RNRLR}RgR%(Rtworker((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pytfinishsN(RRRR(RYRSRRgRR‘R“RžR…R¤(((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyR7Vs  O !     (s User-agentsDMozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0($RR<RyRKRFRQtosRturllib2RRRRRRRtdocutilsRtsphinx.buildersR tsphinx.util.consoleR R R R RRtsphinx.util.pycompatRRRit addheadersRR"R6R7(((sC/usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyt s&     (.