Qc@s'dZdZddlZddlZddlZddlZddlmZmZm Z ddlm Z m Z ddl m Z mZddl mZmZmZde fd YZd e fd YZd e fd YZde fdYZdejfdYZdZddZdS(s Transforms for PEP processing. - `Headers`: Used to transform a PEP's initial RFC-2822 header. It remains a field list, but some entries get processed. - `Contents`: Auto-inserts a table of contents. - `PEPZero`: Special processing for PEP 0. treStructuredTextiN(tnodestutilst languages(tApplicationErrort DataError(t TransformtTransformError(tpartst referencestmisctHeaderscBsYeZdZdZdZdZejdejdfejddffZ dZ RS(s< Process fields in a PEP's initial RFC-2822 header. ihspep-%04ds=http://svn.python.org/view/*checkout*/peps/trunk/pep-%04d.txts\$RCSfile: (.+),v \$$s\1s\$[a-zA-Z]+: (.+) \$$c Csbt|jstdn|jd}t|tj sNd|dkr]tdnd}x-|D]%}|djjdkrj|dj}yt |}|j |}Wnt k r|}d}|jj j d|d |}|jj|}tj||pd d |}|jj|} |j| t|drh|g|dd(q|dctjd d |7R#R9tcompilet IGNORECASER@RU(((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyR stContentscBseZdZdZdZRS(s~ Insert an empty table of contents topic and a transform placeholder into the document after the RFC 2822 header. i|cCstj|jjj|jj}|jd}tjd|}tj d|ddg}tj |}|jj |s|dj |n|jj |tjtj}||7}|jjd||jj|dS(NtcontentsRR tnamesi(Rt get_languageRR<t language_codeR%tlabelsRRttopictfully_normalize_namethas_nameR;tnote_implicit_targetR+RR\R-R.(RAtlanguageRJRRbR+((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyRUs  (RVRWRXRYRU(((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyR\st TargetNotescBs&eZdZdZdZdZRS(s Locate the "References" section, insert a placeholder for an external target footnote insertion transform at the end, and schedule the transform to run immediately. icCs{|j}t|d}d}}x|dkrt||tjr||djjj}d|kr||}Pnd|kr|}n|d8}q&W|stj}|tj dd7}|j ||r|j ||q|j |ntj tj}|j ||jj|dtj tjdi|jd6}|j ||jj|ddS( NiiR t copyrightRt Referencestdetailstcallback(RRRRRtsectionR R!R:RR'R-R;R+R RgR.R tCallBacktcleanup_callback(RAtdoctitrefsectRht title_wordsR+((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyRUs2  %         cCs2t|jdkr.|jjj|jndS(s Remove an empty "References" section. Called after the `references.TargetNotes` transform is complete. iN(Rtparenttremove(RAR+((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyRns(RVRWRXRYRURn(((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyRgs R,cBseZdZdZdZRS(s' Special processing for PEP 0. icCs9t|j}|jj||jjj|jdS(N(tPEPZeroSpecialRtwalkt startnodeRsRt(RAtvisitor((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyRUs(RVRWRXRYRU(((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyR,sRucBsVeZdZejZdZdZdZdZdZ dZ dZ RS(s Perform the special processing needed by PEP 0: - Mask email addresses. - Link PEP numbers in the second column of 4-column tables to the PEPs themselves. cCsdS(N((RARN((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyt unknown_visitscCs|jt|dS(N(R6R7(RARN((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pytvisit_referencescCs d|dkrtjndS(NR R (RtSkipNode(RARN((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pytvisit_field_listscCs |ddk|_d|_dS(Ntcolsii(t pep_tabletentry(RARN((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyt visit_tgroupscCs?|jd7_|jr;|jdkr;|djdndS(NiiR tnum(RR~R;(RARN((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyt visit_colspecscCs d|_dS(Ni(R(RARN((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyt visit_rowscCs|jd7_|jr|jdkrt|dkr|djd|d}t|tjrt|dkr|j}yFt|}|j j j |j |}tj ||d||dR5R$(RARNtpttextRtref((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyt visit_entrys* $     ( RVRWRXR R>RyRzR|RRRR(((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyRus        speps@python.orgspython-list@python.orgspython-dev@python.orgcCs|jdr|djdr|ddtkrC|d}n0|jjdd}tjd|dd }|d kr|S|dcd |7<|g|(|Sn|Sd S( s Mask the email address in `ref` and return a replacement node. `ref` is returned unchanged if it contains no email address. For email addresses such as "user@host", mask the address as "user at host" (text) to thwart simple email address harvesters (except for those listed in `non_masked_addresses`). If a PEP number (`pepno`) is given, return a reference including a default email subject. Rsmailto:iit@s at Rtformatthtmls?subject=PEP%%20%sN(thasattrt startswithtnon_masked_addressesR treplaceRtrawR(RRRt replacementtreplacement_text((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyR7s "   (speps@python.orgspython-list@python.orgspython-dev@python.org(RXt __docformat__tsysR3R9R0tdocutilsRRRRRtdocutils.transformsRRRR R R R\RgR,tSparseNodeVisitorRuRRR7(((s</usr/lib/python2.7/site-packages/docutils/transforms/peps.pyt s$    o23