Xj 2dZddlmZddlmZddlmZddlmZ ddlm Z ejZ ejdd Zej!e e j"e j$e j&d Zd#d Zd$d Zd%d Zd&dZGddej2ZGddeZGddeZGddeZGddeZGddeZe jAedZ!ee!d<ee!d<ee!d<e jAedZ"ee"d <ee"d!<y")'aTemporary stand-in for main oxml module. This module came across with the PackageReader transplant. Probably much will get replaced with objects from the pptx.oxml.core and then this module will either get deleted or only hold the package related custom element classes. ) annotations)cast)etree) NAMESPACE)RELATIONSHIP_TARGET_MODETF)remove_blank_textresolve_entities)ctprrc6tj|tS)z7`etree.fromstring()` replacement that uses oxml parser.)r fromstring oxml_parser)texts a/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/docx/opc/oxml.py parse_xmlr$s   D+ ..cL|jd\}}t|}d|d|S)zStands for "qualified name", a utility function to turn a namespace prefixed tag name into a Clark-notation qualified tag name for lxml. For example, ``qn('p:cSld')`` returns ``'{http://schemas.../main}cSld'``. :{})splitnsmap)tagprefixtagrooturis rqnr)s)iinOFG -CG $$rc2tj|ddS)zSerialize `part_elm` etree element to XML suitable for storage as an XML part. That is to say, no insignificant whitespace added for readability, and an appropriate XML declaration added with UTF-8 encoding specified. zUTF-8T)encoding standalonertostring)part_elms rserialize_part_xmlr%5s >>(W FFrc2tj|ddS)z[Serialize `element` to human-readable XML suitable for tests. No XML declaration. unicodeT)r pretty_printr")elements rserialize_for_readingr*>s >>'ID IIrc"eZdZdZeddZy)BaseOxmlElementzhBase class for all custom element classes, to add standardized behavior to all classes in one place.ct|S)zReturn XML string for this element, suitable for testing purposes. Pretty printed for readability and without an XML declaration at the top. )r*selfs rxmlzBaseOxmlElement.xmlOs %T**rN)returnstr)__name__ __module__ __qualname____doc__propertyr0rrr,r,Ks++rr,cBeZdZdZedZedZeddZy) CT_Defaultz`` element that appears in `[Content_Types].xml` part. Used to specify a default content type to be applied to any part with the specified extension. c$|jdS)zSString held in the ``ContentType`` attribute of this ```` element. ContentTypegetr.s r content_typezCT_Default.content_type^xx &&rc$|jdS)zIString held in the ``Extension`` attribute of this ```` element. Extensionr=r.s r extensionzCT_Default.extensiondsxx $$rc|dtdz}t|}|jd||jd||S)zKReturn a new ```` element with attributes set to parameter values.zr rBr<rrset)extr?r0defaults rnewzCT_Default.newis<&d 3C. K% M<0rN)rGr2r?r2) r3r4r5r6r7r?rC staticmethodrIr8rrr:r:XsC '' %%rr:c@eZdZdZedZedZedZy) CT_Overridezm```` element, specifying the content type to be applied for a part with the specified partname.c$|jdS)zTString held in the ``ContentType`` attribute of this ```` element.r<r=r.s rr?zCT_Override.content_typewr@rc|dtdz}t|}|jd||jd||S)zLReturn a new ```` element with attributes set to parameter values.zr PartNamer<rE)partnamer?r0overrides rrIzCT_Override.new}s<'t4S> Z* ]L1rc$|jdS)zIString held in the ``PartName`` attribute of this ```` element.rOr=r.s rrPzCT_Override.partnamesxx ##rN) r3r4r5r6r7r?rJrIrPr8rrrLrLssC'' $$rrLczeZdZdZeej fddZedZ edZ edZ edZ y) CT_RelationshipzX`` element, representing a single relationship from source to target part.cdtdz}t|}|jd||jd||jd||tjk(r |jdtj|S)z(Return a new ```` element.zr IdTypeTarget TargetMode)rrrFRTMEXTERNAL)rIdreltypetarget target_moder0 relationships rrIzCT_Relationship.newsq+U4[8 ~ s#)6* #,, &   \3<< 8rc$|jdS)zGString held in the ``Id`` attribute of this ```` element.rVr=r.s rr\zCT_Relationship.rIdsxx~rc$|jdS)zIString held in the ``Type`` attribute of this ```` element.rWr=r.s rr]zCT_Relationship.reltypesxxrc$|jdS)zSString held in the ``Target`` attribute of this ```` element.rXr=r.s r target_refzCT_Relationship.target_refsxx!!rcB|jdtjS)zString held in the ``TargetMode`` attribute of this ```` element, either ``Internal`` or ``External``. Defaults to ``Internal``. rY)r>rZINTERNALr.s rr_zCT_Relationship.target_modesxx cll33rN)r\r2r]r2r^r2r_r2) r3r4r5r6rJrZrfrIr7r\r]rdr_r8rrrTrTsnbDGLL    "" 44rrTcLeZdZdZdddZed dZedZedZ y) CT_Relationshipsz>```` element, the root element in a .rels file.c|rtjntj}tj ||||}|j |y)zaAdd a child ```` element with attributes set according to parameter values.N)rZr[rfrTrIappend)r/r\r]r^ is_externalr_r`s radd_relzCT_Relationships.add_rels7'2clls|| &**3M  L!rcLdtdz}ttt|S)z)Return a new ```` element.zr )rrrhr)r0s rrIzCT_Relationships.news$,eDk9$in55rc6|jtdS)zCReturn a list containing all the ```` child elements.zpr:Relationshipfindallrr.s rRelationship_lstz!CT_Relationships.Relationship_lsts||B0122rct|S)zReturn XML string for this element, suitable for saving in a .rels stream, not pretty printed and with an XML declaration at the top.)r%r.s rr0zCT_Relationships.xmls"$''rN)F)r\r2r]r2r^r2rkbool)r1rh) r3r4r5r6rlrJrIr7rqr0r8rrrhrhsFH"66 33((rrhcLeZdZdZdZdZedZedZ edZ y)CT_Typeszh```` element, the container element for Default and Override elements in [Content_Types].xml.cRtj||}|j|y)zJAdd a child ```` element with attributes set to parameter values.N)r:rIrj)r/rGr?rHs r add_defaultzCT_Types.add_defaults..l3 GrcRtj||}|j|y)zSAdd a child ```` element with attributes set to parameter values.N)rLrIrj)r/rPr?rQs r add_overridezCT_Types.add_overrides ??8\: Hrc6|jtdS)Nz ct:Defaultror.s rdefaultszCT_Types.defaultss||B|,--rc4dtdz}t|}|S)z!Return a new ```` element.zr )rr)r0typess rrIz CT_Types.news $eDk1# rc6|jtdS)Nz ct:Overrideror.s r overrideszCT_Types.overridess||B}-..rN) r3r4r5r6rwryr7r{rJrIrr8rrrurusM  .. //rrur DefaultOverrideTypesr Relationship RelationshipsN)rr2r1etree._Element)rr2r1r2)r$rr1bytes)r)rr1r2)#r6 __future__rtypingrlxmlrdocx.opc.constantsrNSrrZElementNamespaceClassLookupelement_class_lookup XMLParserrset_element_class_lookupOPC_CONTENT_TYPESOPC_RELATIONSHIPSOFC_RELATIONSHIPSrrrr%r* ElementBaser,r:rLrTrhru get_namespace ct_namespace pr_namespacer8rrrs4#.>9u88:eoouM $$%9:       / %GJ +e'' +6$/$2&4o&4R((8//>$11%+> $ Y& Z W#11%+> . ^ 0 _r