Ë «4¦™öqÕãó*—dZ ddlmZddlmZddlm Z  ddl m Z e ZddlZeeeej&«dd««d krdd lmZdd lmZ eZ eZd Zd ZdZ Gd„de!«Z"Gd„de#«Z$deddddfd„Z%d„Z&d„Z'd„Z(d!d„Z) d"d„Z* d#d„Z+e,dk(rnddl-Z-ddl.Z. e-j^j`Z/e-jbj`Z1e-jfdd\Z4ee4«Z4d„Z5 e%e/e4e5e ¬ «Z6e4dk(r e5ge6«yyy#e$r ddlmZY�ŒwxYw#e$r ddl m Z n#e$r ddl m Z YnwxYwY�Œ+wxYw#e$reZYŒÿwxYw#e$reZY�Œ wxYw#e2$re-j^Z/e-jbZ1YŒ«wxYw#e7$rYywxYw)$z:Makes working with XML feel like you are working with JSONé)Úpyexpat)Úexpat)Ú XMLGenerator)ÚAttributesImpl)ÚStringIONé)éé)Ú OrderedDict)Ú isgeneratorz Martin Blechz0.13.0ÚMITcó —eZdZy)ÚParsingInterruptedN)Ú__name__Ú __module__Ú __qualname__©óú./usr/lib/python3.12/site-packages/xmltodict.pyrr's„Ørrcóh—eZdZdd„ddddddedd ddd fd „Zd „Zd „Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z y)Ú_DictSAXHandlerrcó—y©NTr)Úargss rÚz_DictSAXHandler..s€¨TrTÚ@ú#textFÚNÚ:z#commentcó—g|_g|_g|_d|_||_||_||_||_||_||_ ||_ ||_ | |_ | |_ | |_| |_| «|_| |_||_y©N)ÚpathÚstackÚdataÚitemÚ item_depthÚ xml_attribsÚ item_callbackÚ attr_prefixÚ cdata_keyÚ force_cdataÚcdata_separatorÚ postprocessorÚdict_constructorÚstrip_whitespaceÚnamespace_separatorÚ namespacesÚnamespace_declarationsÚ force_listÚ comment_key)Úselfr&r(r'r)r*r+r,r-r.r/r0r1r3r4s rÚ__init__z_DictSAXHandler.__init__,s—€ðˆŒ ؈Œ ؈Œ ؈Œ Ø$ˆŒØ&ˆÔØ*ˆÔØ&ˆÔØ"ˆŒØ&ˆÔØ.ˆÔØ*ˆÔØ 0ˆÔØ 0ˆÔØ#6ˆÔ Ø$ˆŒÙ&6Ó&8ˆÔ#Ø$ˆŒØ&ˆÕrcó—|j€|S|j|j«}|dk(r|S|d|||dzd}} |j|}|s|S|jj ||f«S#t$r|}YŒ.wxYw)Néÿÿÿÿé)r1Úrfindr0ÚKeyErrorÚjoin)r5Ú full_nameÚiÚ namespaceÚnameÚshort_namespaces rÚ _build_namez_DictSAXHandler._build_nameOs›€Ø �?‰?Ð "ØÐ Ø �O‰O˜D×4Ñ4Ó 5ˆØ �Š7ØÐ Ø# B Q˜-¨°1°Q±3°4¨�4ˆ ð (Ø"Ÿo™o¨iÑ8ˆOñ؈Kà×+Ñ+×0Ñ0°/À4Ð1HÓIÐ Iøô ò (Ø'ŠOð (ús¿A/Á/ A=Á<A=c ót—t|t«r|S|jt|ddd…|ddd…««S)Nrrr9)Ú isinstanceÚdictr.Úzip)r5Úattrss rÚ_attrs_to_dictz_DictSAXHandler._attrs_to_dict_s=€Ü �eœTÔ "؈LØ×$Ñ$¤S¨¨q¨t°!¨t©°e¸A¸D¸q¸D±kÓ%BÓCÐCrcó*—||j|xsd<y)Nr)r2)r5ÚprefixÚuris rÚstartNamespaceDeclz"_DictSAXHandler.startNamespaceDeclds€Ø47ˆ×#Ñ# F¢L¨bÒ1rcóî—|j|«}|j|«}|r0|jr$|j|d<|j«|_|jj ||xsdf«t |j«|jkDrÞ|jj |j|jf«|jrŒg}|j«D]e\}}|j|j|«z}|jr|j|j||«}n||f}|sŒU|j |«Œg|j|«}nd}|xsd|_ g|_ yy)NÚxmlns)rBrHr2r.r"ÚappendÚlenr&r#r%r$r'Úitemsr)r-)r5r=rGr@Ú attr_entriesÚkeyÚvalueÚentrys rÚ startElementz_DictSAXHandler.startElementgsA€Ø×Ñ  Ó*ˆØ×#Ñ# EÓ*ˆÙ �T×0Ò0Ø!×8Ñ8ˆE�'‰NØ*.×*?Ñ*?Ó*AˆDÔ 'Ø � ‰ ×ј$ ¢ ¨Ð.Ô/Ü ˆt�y‰y‹>˜DŸO™OÒ +Ø �J‰J× Ñ ˜tŸy™y¨$¯)©)Ð4Ô 5Ø×ÒØ!� Ø"'§+¡+¦-‘J�C˜Ø×*Ñ*¨4×+;Ñ+;¸CÓ+@Ñ@�CØ×)Ò)Ø $× 2Ñ 2°4·9±9¸cÀ5Ó I™à!$ e  ˜ÚØ$×+Ñ+¨EÕ2ð#0ð×-Ñ-¨lÓ;‘à�Øš  ˆDŒI؈D�Ið! ,rcóÄ—|j|«}t|j«|jk(ri|j}|€3|j sdn$|j j|j «}|j|j|«}|s t«‚|j�r|j sdn$|j j|j «}|j}|jj«\|_|_|jr|r|j«xsd}|r|jr|€|j«}|�B|r|j!||j"|«|j!|j||«|_n1|j!|j||«|_nd|_g|_|jj«yr!)rBrPr"r&r%r$r,r<r(rr#Úpopr/Ústripr+r.Ú push_datar*)r5r=r@r%Úshould_continuer$s rÚ endElementz_DictSAXHandler.endElement€sm€Ø×Ñ  Ó*ˆÜ ˆt�y‰y‹>˜TŸ_™_Ò ,Ø—9‘9ˆD؈|Ø$(§I¢I™Ø!×1Ñ1×6Ñ6°t·y±yÓAðð#×0Ñ0°·±¸DÓAˆOÙ"Ü(Ó*Ð*Ø �:‹:Ø $§ ¢ ‘DØ×-Ñ-×2Ñ2°4·9±9Ó=ð à—9‘9ˆDØ#'§:¡:§>¡>Ó#3Ñ ˆDŒI�t”yØ×$Ò$©Ø—z‘z“|Ò+ t�Ù˜×(Ò(¨T¨\Ø×,Ñ,Ó.�ØÐÙØ—N‘N 4¨¯©¸Ô>Ø ŸN™N¨4¯9©9°d¸DÓA�• à ŸN™N¨4¯9©9°d¸DÓA�• àˆDŒI؈DŒIØ � ‰ � ‰ �rcód—|js |g|_y|jj|«yr!)r$rO©r5r$s rÚ charactersz_DictSAXHandler.charactersŸs$€Ø�yŠyؘˆD�Ià �I‰I× Ñ ˜TÕ "rcó”—|jr|j«}|j|j|j|«|_yr!)r/rYrZr%r4r^s rÚcommentsz_DictSAXHandler.comments¥s4€Ø × Ò Ø—:‘:“<ˆDØ—N‘N 4§9¡9¨d×.>Ñ.>ÀÓEˆ� rcóP—|j�&|j|j||«}|€|S|\}}|€|j«} ||}t|t«r|j |«|S||g||< |S#t $r$|j||«r |g||<Y|S|||<Y|SwxYwr!)r-r"r.rDÚlistrOr;Ú_should_force_list)r5r%rSr$ÚresultrTs rrZz_DictSAXHandler.push_dataªsÐ€Ø × Ñ Ð )Ø×'Ñ'¨¯ © °3¸Ó=ˆF؈~Ø� ؉IˆC�Ø ˆ<Ø×(Ñ(Ó*ˆDð !ؘ‘IˆEܘ%¤Ô&Ø— ‘ ˜TÔ"ðˆ ð # D˜M��S’ ð ˆ øô ò !Ø×&Ñ& s¨DÔ1Ø!˜F��S’ ðˆ ð!��S’ ؈ ð  !úsÁ&A8Á.A8Á8!B%ÂB%Â$B%cóä—|jsyt|jt«r |jS ||jvS#t$r#|j|jdd||«cYSwxYw)NFr8)r3rDÚboolÚ TypeErrorr")r5rSrTs rrdz"_DictSAXHandler._should_force_list¿sd€Ø�ŠØÜ �d—o‘o¤tÔ ,Ø—?‘?Ð "ð ?ؘ$Ÿ/™/Ð)Ð )øÜò ?Ø—?‘? 4§9¡9¨S¨b >°3¸Ó>Ò >ð ?úsµ AÁ)A/Á.A/)rrrÚ_dictr6rBrHrLrVr\r_rarZrdrrrrr+sb„àÙ1Ø!Ø Ø"Ø"Ø!#Ø#Ø"'Ø"&Ø%(Ø Ø Ø'ó!'òFJò Dò 8òò2ò>#ò Fò ó*?rrFrTc ó—td d|i|¤Ž}t|t«r|sd}|j|«}|sd}|j||«} d| _|j| _|j| _ |j| _ |j| _|r|j| _d| _|r d} | j$j'| d«t-|d«r| j/|«|j4St1|«r7|D]} | j3| d «Œ| j3d d«|j4S| j3|d«|j4S#t $rY�ŒwxYw#t $rd„| _d„| _YŒ´wxYw) aParse the given XML input and convert it into a dictionary. `xml_input` can either be a `string`, a file-like object, or a generator of strings. If `xml_attribs` is `True`, element attributes are put in the dictionary among regular child elements, using `@` as a prefix to avoid collisions. If set to `False`, they are just ignored. Simple example:: >>> import xmltodict >>> doc = xmltodict.parse(""" ... ... 1 ... 2 ... ... """) >>> doc['a']['@prop'] u'x' >>> doc['a']['b'] [u'1', u'2'] If `item_depth` is `0`, the function returns a dictionary for the root element (default behavior). Otherwise, it calls `item_callback` every time an item at the specified depth is found and returns `None` in the end (streaming mode). The callback function receives two parameters: the `path` from the document root to the item (name-attribs pairs), and the `item` (dict). If the callback's return value is false-ish, parsing will be stopped with the :class:`ParsingInterrupted` exception. Streaming example:: >>> def handle(path, item): ... print('path:%s item:%s' % (path, item)) ... return True ... >>> xmltodict.parse(""" ... ... 1 ... 2 ... """, item_depth=2, item_callback=handle) path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:1 path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:2 The optional argument `postprocessor` is a function that takes `path`, `key` and `value` as positional arguments and returns a new `(key, value)` pair where both `key` and `value` may have changed. Usage example:: >>> def postprocessor(path, key, value): ... try: ... return key + ':int', int(value) ... except (ValueError, TypeError): ... return key, value >>> xmltodict.parse('12x', ... postprocessor=postprocessor) {'a': {'b:int': [1, 2], 'b': 'x'}} You can pass an alternate version of `expat` (such as `defusedexpat`) by using the `expat` parameter. E.g: >>> import defusedexpat >>> xmltodict.parse('hello', expat=defusedexpat.pyexpat) {'a': 'hello'} You can use the force_list argument to force lists to be created even when there is only a single child of a given level of hierarchy. The force_list argument is a tuple of keys. If the key for a given level of hierarchy is in the force_list argument, that level of hierarchy will have a list as a child (even if there is only one sub-element). The index_keys operation takes precedence over this. This is applied after any user-supplied postprocessor has already run. For example, given this input: host1 Linux em0 10.0.0.1 If called with force_list=('interface',), it will produce this dictionary: {'servers': {'server': {'name': 'host1', 'os': 'Linux'}, 'interfaces': {'interface': [ {'name': 'em0', 'ip_address': '10.0.0.1' } ] } } } `force_list` can also be a callable that receives `path`, `key` and `value`. This is helpful in cases where the logic that decides whether a list should be forced is more complex. If `process_comment` is `True` then comment will be added with comment_key (default=`'#comment'`) to then tag which contains comment For example, given this input: 1 2 If called with process_comment=True, it will produce this dictionary: 'a': { 'b': { '#comment': 'b comment', 'c': { '#comment': 'c comment', '#text': '1', }, 'd': '2', }, } r0úutf-8NTz4http://apache.org/xml/features/disallow-doctype-declcó—yr!r©Úxs rrzparse..ps€¨drcó—y)Nr9rrms rrzparse..rs€¸rÚreadFrr)rrDÚ_unicodeÚencodeÚ ParserCreateÚordered_attributesÚAttributeErrorrLÚStartNamespaceDeclHandlerrVÚStartElementHandlerr\ÚEndElementHandlerr_ÚCharacterDataHandlerraÚCommentHandlerÚ buffer_textÚ_readerÚ setFeatureÚDefaultHandlerÚExternalEntityRefHandlerÚhasattrÚ ParseFiler ÚParser%) Ú xml_inputÚencodingrÚprocess_namespacesr0Údisable_entitiesÚprocess_commentsÚkwargsÚhandlerÚparserÚfeatureÚchunks rÚparser�Ês•€ôLñ(Ð2Eð(Ø &ñ(€Gä�)œXÔ&ÙØˆHØ×$Ñ$ XÓ.ˆ Ù Ø"ÐØ ˆU× Ñ ØØó€Fð Ø$(ˆÔ!ð(/×'AÑ'A€FÔ$Ø!(×!5Ñ!5€FÔØ&×1Ñ1€FÔØ")×"4Ñ"4€FÔÙØ '× 0Ñ 0ˆÔØ€FÔÙð ;àLˆGØ �N‰N× %Ñ % g¨tÔ 4ôˆy˜&Ô!Ø×јÔ#ð �<‰<Ðô �YÔ ÛˆEØ �L‰L˜˜uÕ %ðà� ‰ �S˜Ôð �<‰<Ðð � ‰ �Y Ô%Ø �<‰<Ðøô; ò â ð ûôò ;ñ%3ˆFÔ !á.:ˆFÖ +ð  ;ús$Á EÂ3E*Å E'Å&E'Å*FÆFcó:—t|t«xr d|vxsd|vS)zˆReturn True if value (a str) contains '<' or '>'. Non-string values return False. Uses fast substring checks implemented in C. Ú<Ú>)rDÚstr©rTs rÚ_has_angle_bracketsr“~s#€ô �eœSÓ !Ò D s¨e |Ò'C°s¸e°|ÐDrcób—t|t«syd|vsd|vsd|vrytd„|D««S)z«Return True if value (a str) contains any disallowed name characters. Disallowed: '<', '>', '/', or any whitespace character. Non-string values return False. Fr�r�Ú/Tc3ó<K—|]}|j«–—Œy­wr!©Úisspace©Ú.0Úchs rÚ z*_has_invalid_name_chars..‘sèø€Ð,¡e ˆr�z‰z�|¡eùó‚)rDr‘Úanyr’s rÚ_has_invalid_name_charsrŸ†s8€ô �eœSÔ !ØØ ˆe�|�s˜e‘| s¨e¡|Øä Ñ,¡eÓ,Ó ,Ð,rcó8—t|t«st|›d�«‚|jd«s|jd«rtd|›d�«‚d|vsd|vrtd|›d�«‚d |vrtd|›d �«‚t d „|D««rtd|›d �«‚y )z°Validate an element/attribute name for XML safety. Raises ValueError with a specific reason when invalid. kind: 'element' or 'attribute' (used in error messages) z name must be a stringÚ?Ú!zInvalid z# name: cannot start with "?" or "!"r�r�z name: "<" or ">" not allowedr•z name: "/" not allowedc3ó<K—|]}|j«–—Œy­wr!r—r™s rrœz!_validate_name..£sèø€Ð (¡%˜Bˆ2�:‰:�<¡%ùr�z name: whitespace not allowedN)rDr‘Ú ValueErrorÚ startswithrž)rTÚkinds rÚ_validate_namer§”s·€ô �eœSÔ !ܘD˜6Ð!7Ð8Ó9Ð9Ø ×Ñ˜Ô × 0Ñ 0°Ô 5ܘ8 D 6Ð)LÐMÓNÐNØ ˆe�|�s˜e‘|ܘ8 D 6Ð)FÐGÓHÐHØ ˆe�|ܘ8 D 6Ð)?Ð@ÓAÐAÜ Ñ (¡%Ó (Ô(ܘ8 D 6Ð)FÐGÓHÐHð)rcó—t|t«s|S|s|S |j|d«\}}|j|j |««}|r)dj |j |«r|nd|||«}|S|}|S#t$rY|SwxYw)Nr9z{}{}{}{}r)rDr‘ÚrsplitÚgetrYÚformatr¥r¤)r@r1Úns_sepr)ÚnsÚns_ress rÚ_process_namespacer¯§s¬€Ü �dœCÔ Øˆ ٠؈ ð6Ø—;‘;˜v qÓ)‰ˆˆDð—‘ §¡¨Ó 5Ó6ˆñ&,ð× Ñ ØŸ=™=¨Ô5‰K¸2Ø �F˜Dó"ˆð €Kð26ð ð €Køô ò Ø ð €Kð ús˜A<Á< B ÂB cóü—t|| | |«}|�|||«}|€y|\}}t|d«t|d«r t|t«st|t «r|g}t |«D�]‘\}}| r|dk(r|dkDr td«‚|€ t«}nrt|t«r|r td«}nTtd«}nHt|t «s8| r+t|d«rt|t«st| |ff«}n t|«}t|t«rt||ff«}d}t«}g}|j«D]ö\}}||k(r|}Œt|t«rÆ|j|«rµt|| | |«}|dk(rgt|t «rW|j«D]C\}}t|d«d j|rd j|«nd «}t|«||<ŒEŒ©t|t«s t|«}|t|«d}t|d«|||<Œä|j!||f«Œø|r|j#|| z«|j%|t'|««|r|r|j#|«|D] \}}t)||||||d z|||| | | | ¬ « Œ"|�|j+|«|r|r|j#|| z«|j-|«|s�Œ}|s�Œ�|j#|«�Œ”y)NÚelementÚ__iter__rzdocument with multiple rootsÚtrueÚfalsez@xmlnsÚ attributezxmlns{}z:{}rr9)r1r0Ú expand_iter)r¯r§r€rDÚ _basestringrEÚ enumerater¤rirgrqrQr‘r¥r«rPrOÚignorableWhitespacerVrÚ_emitr_r\)rSrTÚcontent_handlerr)r*ÚdepthÚ preprocessorÚprettyÚnewlÚindentr0r1Ú full_documentr¶reÚindexÚvÚcdatarGÚchildrenÚikÚivÚkÚattrÚ attr_nameÚ child_keyÚ child_values rrºrº¸sã€ô ˜S *Ð.AÀ;Ó O€CØÐÙ˜c 5Ó)ˆØ ˆ>Ø Ø‰ ˆˆUä�3˜ Ô"Ü �E˜:Ô &ܘ%¤Ô-ܘ%¤Ô&Ø�ˆÜ˜e×$‰ˆˆqÙ ˜U ašZ¨E°AªIÜÐ;Ó<Ð <Ø ˆ9Ü“‰AÜ ˜œ4Ô ÙܘVÓ$‘ä˜WÓ%‘ܘAœtÔ$Ùœw q¨*Ô5¼jÈÌKÔ>XܘK¨Ð+Ð-Ó.‘ä˜Q“K�Ü �aœÔ %ܘ  1�~Ð'Ó(ˆA؈ܓˆØˆØ—g‘g–i‰FˆB�Ø�YŠØ�ØÜ˜"œcÔ" r§}¡}°[Ô'AÜ'¨¨JÐ8KØ(3ó5�à˜’>¤j°´TÔ&:Ø "§¡¦ ™˜˜1Ü& q¨+Ô6Ø(×/Ñ/Á1°· ± ¸Q´È"ÓM˜Ü&.¨q£k˜˜dš ð!+ðÜ! "¤hÔ/Ü! "›�BØœs ;Ó/Ð1Ð2� ܘy¨+Ô6Ø#%��iÑ ØØ �O‰O˜R ˜HÕ %ð' ñ( Ø × /Ñ /°¸±Ô ?Ø×$Ñ$ S¬.¸Ó*?Ô@Ù ‘hØ × /Ñ /°Ô 5Û&.Ñ "ˆI�{Ü �)˜[¨/ؘy¨%°©'°<ؘ$ °:Ø&9Ø)ö  +ð'/ð Ð Ø × &Ñ & uÔ -Ù ‘hØ × /Ñ /°¸±Ô ?Ø×"Ñ" 3Ô'Û “eØ × /Ñ /°Ö 5ñs%rc ó–—|rt|«dk7r td«‚d}|€ t«}d}|rt||d«}n t||«}|r|j «|j «D]\}} t || |fd|i|¤ŽŒ|r|j«|r$|j«} | j|«} | Sy#t$rY| SwxYw)axEmit an XML document for the given `input_dict` (reverse of `parse`). The resulting XML document is returned as a string, but if `output` (a file-like object) is specified, it is written there instead. Dictionary keys prefixed with `attr_prefix` (default=`'@'`) are interpreted as XML node attributes, whereas keys equal to `cdata_key` (default=`'#text'`) are treated as character data. The `pretty` parameter (default=`False`) enables pretty-printing. In this mode, lines are terminated with `' '` and indented with `' '`, but this can be customized with the `newl` and `indent` parameters. r9z$Document must have exactly one root.FNTrÁ) rPr¤rrÚ startDocumentrQrºÚ endDocumentÚgetvalueÚdecoderu) Ú input_dictÚoutputr„rÁÚshort_empty_elementsrˆÚ must_returnr»rSrTs rÚunparserÖ sì€ñ"œ˜Z›¨AÒ-ÜÐ?Ó@Ð@Ø€KØ €~Ü“ˆØˆ ÙÜ& v¨x¸Ó>‰ä& v¨xÓ8ˆÙØ×%Ñ%Ô'Ø ×&Ñ&Ö(‰ ˆˆUÜ ˆc�5˜/ñ ¸ð Øó ð)ñØ×#Ñ#Ô%ÙØ—‘Ó!ˆð Ø—L‘L Ó*ˆEðˆ ð øôò Ø Øˆ ð úsÂ'B;Â; CÃCÚ__main__r9có<—tj||ft«yr)ÚmarshalÚdumpÚstdout)r"r%s rÚ handle_itemrÜDs€Ü� ‰ �d˜D�\¤6Ô*Ør)r&r(r.)rr) rrrNFÚ Ú rNTN)NrkTF)8Ú__doc__Ú defusedexpatrrÚ ImportErrorÚ xml.parsersÚxml.sax.saxutilsrÚxml.sax.xmlreaderrÚ cStringIOrÚiorEriÚplatformÚtupleÚmapÚintÚpython_version_tupleÚ collectionsr Úinspectr Ú basestringr·Ú NameErrorr‘ÚunicoderqÚ __author__Ú __version__Ú __license__Ú ExceptionrÚobjectrr�r“rŸr§r¯rºrÖrÚsysrÙÚstdinÚbufferrÛruÚargvr&rÜÚrootÚKeyboardInterruptrrrÚrüs+ðá<ð"Ý-õ*Ý,ð Ý"ð €ÛÙ‰ˆSÐ/�(×/Ñ/Ó1°"°1Ð5Ó 6Ó7¸&Ò@Ý0åðØ€KðØ€Hð€ Ø€ Ø€ ô ˜ô ô\?�fô\?ð~#¨%ÀEØ!°DÈ5óqòhEò -òIó&ð$ØØØØØØØ!ØØØóQ6ðhFJØ!&ó(ðV ˆzÒÛÛðØ— ‘ × Ñ ˆØ—‘×"Ñ"ˆð —H‘H˜Q˜R�L�M€ZÙ�Z“€Jòð Ù�UØ *Ø#.Ø&*ô,ˆð ˜Š?Ù ˜˜DÕ !ð ð-øðcò"ß!Ð!ð"ûð ò ð Þ%øØ ò ßð ýð ûðòØ‚Kðûðò؃Hðûð| òØ— ‘ ˆØ—‘Šðûð$ ò Ù ð úsŽ„D—D'ÁE ÁEÂ/,E'Ã8F Ä D$Ä#D$Ä'E Ä-D4Ä3E Ä4 EÄ?E ÅEÅE ÅE Å EÅEÅE$Å#E$Å'FÆFÆ FÆF