B ¡w­\0+ã@sÔdZdZddlZddlZddlZddlZddlmZmZm Z ddlm Z m Z ddl m Z mZddl mZmZmZGdd „d e ƒZGd d „d e ƒZGd d „d e ƒZGdd„de ƒZGdd„dejƒZdZddd„ZdS)zø 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. ZreStructuredTextéN)ÚnodesÚutilsÚ languages)ÚApplicationErrorÚ DataError)Ú TransformÚTransformError)ÚpartsÚ referencesÚmiscc@sDeZdZdZdZdZdZe dej ¡dfe d¡dffZ dd „Z d S) ÚHeadersz< Process fields in a PEP's initial RFC-2822 header. ihzpep-%04dz3http://hg.python.org/peps/file/default/pep-%04d.txtz\$RCSfile: (.+),v \$$z\1z\$[a-zA-Z]+: (.+) \$$c Cs(t|jƒstdƒ‚|jd}t|tjƒr4d|dkr}t|ƒ}| !tj|||jj"j#|j$|d¡| !|¡q W|dd…|dd…<n¦| dkrºt% &||j'¡|r| ¡} tjd | |dg|dd…<nd| dkrü| ¡}|jj"j#|j$d }tjd ||dg|dd…<n"| d!krªt| ƒrªt% &||j'¡qªWdS)"NzDocument tree is empty.rÚrfc2822ÚclasseszADocument does not begin with an RFC-2822 header; it is not a PEP.Úpepéz?"PEP" header must contain an integer; "%s" is an invalid value.)Z base_nodez(none))ZrefidÚz3Document does not contain an RFC-2822 "PEP" header.éÚtitlez No title!z4PEP header field body contains multiple elements: %s)Úlevelz=PEP header field body may only contain a single paragraph: %sz last-modifiedz%d-%b-%YÚsourceé)ÚrefuriÚauthorzdiscussions-to)Zreplacesz replaced-byÚrequiresú z,?\s+éÿÿÿÿz content-typeé Úversion)(ÚlenÚdocumentrÚ isinstancerZ field_listÚastextÚlowerÚintÚ pep_cvs_urlÚ ValueErrorÚreporterÚwarningÚset_idZ problematicZ add_backrefÚ paragraphÚpendingÚPEPZeroÚinsertÚ note_pendingÚpformatÚtimeÚstrftimeÚ localtimeÚosÚstatÚ referenceÚ replace_selfÚ mask_emailZTextÚreÚsplitÚappendÚsettingsÚ pep_base_urlÚpep_urlrZclean_rcs_keywordsÚrcs_keyword_substitutions)ÚselfÚheaderrÚfieldÚvalueZcvs_urlÚmsgÚmsgidZprbZprbidr*ÚnameÚbodyÚdateÚparaÚnodeZnewbodyÚspaceZrefpepÚpepnoZpep_typeÚuri©rLúr/private/var/folders/j5/hv2kzfgs4sl6jnf70fy_2vrc4p3c_b/T/pip-install-d8kq1y21/docutils/docutils/transforms/peps.pyÚapply)sª                (         z Headers.applyN) Ú__name__Ú __module__Ú __qualname__Ú__doc__Údefault_priorityr<r$r7ÚcompileÚ IGNORECASEr=rNrLrLrLrMr sr c@seZdZdZdZdd„ZdS)ÚContentsz~ Insert an empty table of contents topic and a transform placeholder into the document after the RFC 2822 header. i|cCs t |jjj|jj¡}|jd}t d|¡}tj d|dgd}t  |¡}|j  |¡sb|d  |¡|j  |¡t tj¡}||7}|j d|¡|j |¡dS)NÚcontentsr)rÚnamesr)rZ get_languagerr:Z language_coder&ÚlabelsrrÚtopicZfully_normalize_nameZhas_namer9Znote_implicit_targetr*r rVr,r-)r>ÚlanguagerDrrZr*rLrLrMrN’s        zContents.applyN)rOrPrQrRrSrNrLrLrLrMrV‰srVc@s$eZdZdZdZdd„Zdd„ZdS)Ú TargetNotesz¶ 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\|dkrvt||tjƒrv||d ¡ ¡ ¡}d|kr`||}Pn d|krl|}|d8}qW|sºt ¡}|t dd¡7}|  |¡|r°|  ||¡n |  |¡t  t j¡}|  |¡|j |d¡tj tjd|jid}|  |¡|j |d¡dS) Nrrr Ú copyrightrZ ReferencesÚcallback)Údetails)rrr rÚsectionr!r"r8rr(r,r9r*r r\r-r ZCallBackÚcleanup_callback)r>ÚdocÚiZrefsectr]Z title_wordsr*rLrLrMrN¬s2       zTargetNotes.applycCs"t|jƒdkr|jj |j¡dS)z Remove an empty "References" section. Called after the `references.TargetNotes` transform is complete. rN)rÚparentÚremove)r>r*rLrLrMraÊszTargetNotes.cleanup_callbackN)rOrPrQrRrSrNrarLrLrLrMr\¢sr\c@seZdZdZdZdd„ZdS)r+z' Special processing for PEP 0. iøcCs*t|jƒ}|j |¡|jj |j¡dS)N)ÚPEPZeroSpecialrÚwalkZ startnoderdre)r>ZvisitorrLrLrMrNÜs  z PEPZero.applyN)rOrPrQrRrSrNrLrLrLrMr+Ôsr+c@sNeZdZdZejZdd„Zdd„Zdd„Zdd „Z d d „Z d d „Z dd„Z dS)rfz´ 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)NrL)r>rHrLrLrMÚ unknown_visitïszPEPZeroSpecial.unknown_visitcCs| t|ƒ¡dS)N)r5r6)r>rHrLrLrMÚvisit_referenceòszPEPZeroSpecial.visit_referencecCsd|dkrtj‚dS)Nr r)rZSkipNode)r>rHrLrLrMÚvisit_field_listõs zPEPZeroSpecial.visit_field_listcCs|ddk|_d|_dS)NÚcolsér)Ú pep_tableÚentry)r>rHrLrLrMÚ visit_tgroupùszPEPZeroSpecial.visit_tgroupcCs0|jd7_|jr,|jdkr,|d d¡dS)NrrrÚnum)rnrmr9)r>rHrLrLrMÚ visit_colspecýszPEPZeroSpecial.visit_colspeccCs d|_dS)Nr)rn)r>rHrLrLrMÚ visit_rowszPEPZeroSpecial.visit_rowcCs®|jd7_|jrª|jdkrªt|ƒdkrª|d d¡|d}t|tjƒrªt|ƒdkrª| ¡}y4t|ƒ}|j j j |j |}tj |||d|d<Wntk r¨YnXdS)Nrrrrpr)r)rnrmrr9r rr)r!r#rr:r;r<r4r%)r>rHÚpÚtextrÚrefrLrLrMÚ visit_entrys zPEPZeroSpecial.visit_entryN) rOrPrQrRr r<rhrirjrorqrrrvrLrLrLrMrfâs rf)zpeps@python.orgzpython-list@python.orgzpython-dev@python.orgcCs’| d¡rŠ|d d¡rŠ|ddd…tkr6|d}n | ¡ dd¡}tjd|d d }|dkrb|S|dd |7<|g|dd…<|Sn|SdS) a¨ 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. rzmailto:rNrú@z at rÚhtml)Úformatz?subject=PEP%%20%s)ÚhasattrÚ startswithÚnon_masked_addressesr!ÚreplacerÚraw)rurJÚ replacementZreplacement_textrLrLrMr6s  r6)N)rRZ __docformat__Úsysr2r7r/ZdocutilsrrrrrZdocutils.transformsrrr r r r rVr\r+ZSparseNodeVisitorrfr|r6rLrLrLrMÚ s o23