jf1&dZdZddlZddlZddlmZmZddlmZddl m Z GddeZ Gd d eZ Gd d eZ Gd deZGddeZGddeZGddeZGddeZdS)a Transforms needed by most or all documents: - `Decorations`: Generate a document's header & footer. - `ExposeInternals`: Expose internal attributes. - `Messages`: Placement of system messages generated after parsing. - `FilterMessages`: Remove system messages below verbosity threshold. - `TestMessages`: Like `Messages`, used on test runs. - `StripComments`: Remove comment elements from the document tree. - `StripClassesAndElements`: Remove elements with classes in `self.document.settings.strip_elements_with_classes` and class values in `self.document.settings.strip_classes`. - `SmartQuotes`: Replace ASCII quotation marks with typographic form. reStructuredTextN)nodesutils) Transform) smartquotesc(eZdZdZdZdZdZdZdS) DecorationszD Populate a document's decoration element (header, footer). i4cj|}|rB|j}|}|||}|rD|j}|}||dSdSN)generate_headerdocumentget_decoration get_headerextendgenerate_footer get_footer)self header_nodes decorationheader footer_nodesfooters }/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/transforms/universal.pyapplyzDecorations.apply&s++--  (5577J**,,F MM, ' ' '++--  (5577J**,,F MM, ' ' ' ' ' ( (cdSr )rs rr zDecorations.generate_header2strc F|jj}|js|js|js|jrwg}|jr|js|jrl|jr|j}ntj|j |j}| tj dd|tj dg|jrXtj|jtj}|tj d|zdz|jrz| tj dtj dddtj d tj dd d tj d gtjddg|RgSdS) NzView document source)refuriz. zGenerated on: z Generated by Docutilsz https://docutils.sourceforge.io/z from rz(https://docutils.sourceforge.io/rst.htmlz source. )r settings generator datestamp source_link source_url_sourcer relative_path _destinationrr referenceTexttimestrftimegmtimeappend paragraph)rr"textsourcer$s rrzDecorations.generate_footer5s=)   ("4 # '/': D$ ()9 (& (&C%0FF"01F191ACCF OB(>+1333Ju%%'(((! N M(*getattr)rr=attvalues rrzExposeInternals.applyhs = ! 2 8 --dm<< 8 8=1B88C#D#t44E(27[3./8 8 8 8 8rN)r3r4r5r6r7r>rrrrr9r9]sD00088888rr9ceZdZdZdZdZdS)Messageszi Place any system messages generated after parsing into a dedicated section of the document. i\c|jj}d|D}|rVtjdg}|tjddz }||z }g|jjdd<|xj|z c_dSdS)Nc g|] }|j | Sr)parent).0msgs r z"Messages.apply..|sDDD#D#DDDrsystem-messages)classesrzDocutils System Messages)r transform_messagesrsectiontitle)rmessagesloose_messagesrPs rrzMessages.applyzs=3DDDDD  %m->,?@@@G u{2'ABB BG ~ %G24DM ,QQQ / MMW $MMMM  % %rNr3r4r5r6r7rrrrrFrFqs5  % % % % %rrFceZdZdZdZdZdS)FilterMessagesz Remove system messages below verbosity threshold. Convert nodes referencing removed messages to . Remove "System Messages" section if empty. ifct|jtjD]b}|d|jjjkrE|j| |jj |dd=R#t$rY^wxYwct|jtj D]U}|d|jj vr?|j |tj |V|jtjD]9}d|dvr-t!|dkr|j|:dS)NlevelidsrrefidrMrN)tupler rArsystem_messagereporter report_levelrIremoverY IndexError problematicreplacer+astextrPlenr<s rrzFilterMessages.applysh$-//0DEEFF  DG}t}5BBB ""4((( )$u+a.99"D C $-//0ABBCC E EDG}DM$555 ##D%*T[[]]*C*CDDDM))%-88 ) )D DO33D Q ""4((( ) )s*B BBNrTrrrrVrVs5 ) ) ) ) )rrVc eZdZdZdZdZdZdS) TestMessageszk Append all post-parse system messages to the end of the document. Used for testing purposes. FipcR|jjD]}|js|xj|z c_dSr )r rOrI)rrKs rrzTestMessages.applys;=3 % %C: % $  % %rN)r3r4r5r6__test__r7rrrrrgrgs:H%%%%%rrgceZdZdZdZdZdS) StripCommentszq Remove comment elements from the document tree (only if the ``strip_comments`` setting is enabled). ic|jjjrNt|jt jD]}|j|dSdSr ) r r"strip_commentsr\rArcommentrIr`r<s rrzStripComments.applysh = ! 0 )dm33EMBBCC ) ) ""4(((( ) ) ) )rNrTrrrrkrks5 )))))rrkc"eZdZdZdZdZdZdS)StripClassesAndElementsz Remove from the document tree all elements with classes in `self.document.settings.strip_elements_with_classes` and all "classes" attribute values in `self.document.settings.strip_classes`. ic|jjjrah|jjj|_t |j|jD]}|j||jjj sdS|jjj }|jtj D]3}|D].} |d|#t$rY+wxYw4dS)NrN) r r"strip_elements_with_classesstrip_elementsr\rA check_classesrIr` strip_classesrElement ValueError)rr=ru class_values rrzStripClassesAndElements.applys = ! = )#ADM$:$?#AD dm33D4FGGHH ) ) ""4((((}%3  F .< M))%-88  D,   O**;7777!D   sC C+*C+c|t|tjsdS|dddD]}||jvrdSdS)NFrNT)r;rrvrs)rr=rxs rrtz%StripClassesAndElements.check_classessV$ .. 5 ?111-  Kd111tt2urN)r3r4r5r6r7rrtrrrrprpsD &rrpceZdZdZdZejejfZ ejejej ej ej ej ej fZ dZ dZdZdZdS) SmartQuotesz Replace ASCII quotation marks with typographic form. Also replace multiple dashes with em-dash/en-dash characters. iWqDecZtj|||t|_dS)N) startnode)r__init__setunsupported_languages)rr r~s rrzSmartQuotes.__init__s,4Y????%(UU"""rc#K|D]x}t|j|jst|jj|jrdt|fVOt jddt|}d|fVydS)Nliteralz(?<=)([-\'".`])z\\\1plain)r;rI literal_nodesstrresub)rtxtnodesr=txts r get_tokenszSmartQuotes.get_tokens s # #D4;(:;; #dk0$2DEE #T*****f4gs4yyIIsl"""" # #rc|jjdd}|sdS |d}n#t$rd}YnwxYw|jjj}|jjj}|r1tjj t||j tjD]}t||jrt|jtjr9d| tjD}||}|r d|vr|dd}n|dz }t+j|D]}|tjj vr|}nJ||jvr$|jjd|z||j|d}tj|||j| } t=|| D]2\} } | j| tj| 3|jdS) N smart_quotesFaltcPg|]#}t|jtj!|$Sr)r;rIr option_string)rJtxtnodes rrLz%SmartQuotes.apply..3sG@@@G)'.*/*= ? ?@@@@rz -x-altquotrz*No smart quotes defined for language "%s".) base_node)attrlanguage) r r" setdefault startswithAttributeError language_codesmartquotes_localesr smartcharsquotesupdatedictrAr TextElementr; nodes_to_skiprIr+get_language_codercrnormalize_language_tagrr^warningaddeducate_tokensrsmartquotes_actionzipclear) rr alternativedocument_languagelc_smartquotesr=rlangtagteacherrnewtexts rrzSmartQuotes.applys}-889>@@   F &11%88KK   KKK !M2@/C  G  " ) 0 0n1E1E F F FM))%*;<<) E) ED$ 233 $+u'899 @@t||EJ/G/G@@@H ))*;<rs  # !!!!!!!!))))))&&&&&&<<<<<)<<<~88888i888(%%%%%y%%%6)))))Y)))6%%%%%9%%%& ) ) ) ) )I ) ) )#####i###Lf+f+f+f+f+)f+f+f+f+f+r