
    ,h.                     .   d Z ddlmZ ddlmZ ddlmZ ddlmZ	 ddlm
Z  ej                         Z ej                  dd	      Zej!                  e       e	j"                  e	j$                  e	j&                  d
Zd#dZd Zd$dZd Z G d dej2                        Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      ZejA                  ed         Z!ee!d<   ee!d<   ee!d<   ejA                  ed         Z"ee"d <   ee"d!<   y")%a  Temporary 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_textresolve_entities)ctprrc                6    t        j                  | t              S )z7`etree.fromstring()` replacement that uses oxml parser.)r   
fromstringoxml_parser)texts    O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/opc/oxml.py	parse_xmlr   $   s    D+..    c                L    | j                  d      \  }}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'``.
    :{})splitnsmap)tagprefixtagrooturis       r   qnr   )   s)     iinOFG
-CG$$r   c                2    t        j                  | dd      S )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.
    zUTF-8T)encoding
standaloner   tostring)part_elms    r   serialize_part_xmlr%   5   s     >>(WFFr   c                2    t        j                  | dd      S )z[Serialize `element` to human-readable XML suitable for tests.

    No XML declaration.
    unicodeT)r    pretty_printr"   )elements    r   serialize_for_readingr*   >   s    
 >>'IDIIr   c                       e Zd ZdZed        Zy)BaseOxmlElementzhBase class for all custom element classes, to add standardized behavior to all
    classes in one place.c                    t        |       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    r   xmlzBaseOxmlElement.xmlO   s     %T**r   N)__name__
__module____qualname____doc__propertyr0    r   r   r,   r,   K   s     + +r   r,   c                  @    e Zd ZdZed        Zed        Zed        Zy)
CT_Defaultzt``<Default>`` element, specifying the default content type to be applied to a
    part with the specified extension.c                $    | j                  d      S )zSString held in the ``ContentType`` attribute of this ``<Default>``
        element.ContentTypegetr.   s    r   content_typezCT_Default.content_type\        xx&&r   c                $    | j                  d      S )zIString held in the ``Extension`` attribute of this ``<Default>`` element.	Extensionr;   r.   s    r   	extensionzCT_Default.extensionb   s     xx$$r   c                |    dt         d   z  }t        |      }|j                  d|        |j                  d|       |S )zSReturn a new ``<Default>`` element with attributes set to parameter
        values.z<Default xmlns="%s"/>r
   r@   r:   r   r   set)extr=   r0   defaults       r   newzCT_Default.newg   s<     &d3C.K%M<0r   N)	r1   r2   r3   r4   r5   r=   rA   staticmethodrG   r6   r   r   r8   r8   X   sC    * ' '
 % %  r   r8   c                  @    e Zd ZdZed        Zed        Zed        Zy)CT_Overridezm``<Override>`` element, specifying the content type to be applied for a part with
    the specified partname.c                $    | j                  d      S )zTString held in the ``ContentType`` attribute of this ``<Override>``
        element.r:   r;   r.   s    r   r=   zCT_Override.content_typev   r>   r   c                |    dt         d   z  }t        |      }|j                  d|        |j                  d|       |S )zTReturn a new ``<Override>`` element with attributes set to parameter
        values.z<Override xmlns="%s"/>r
   PartNamer:   rC   )partnamer=   r0   overrides       r   rG   zCT_Override.new|   s<     't4S>Z*]L1r   c                $    | j                  d      S )zIString held in the ``PartName`` attribute of this ``<Override>`` element.rM   r;   r.   s    r   rN   zCT_Override.partname   s     xx
##r   N)	r1   r2   r3   r4   r5   r=   rH   rG   rN   r6   r   r   rJ   rJ   r   sC     ' '
   $ $r   rJ   c                  z    e Zd ZdZeej                  fdd       Zed        Z	ed        Z
ed        Zed        Zy)	CT_Relationshipzb``<Relationship>`` element, representing a single relationship from a source to a
    target part.c                   dt         d   z  }t        |      }|j                  d|        |j                  d|       |j                  d|       |t        j                  k(  r |j                  dt        j                         |S )z(Return a new ``<Relationship>`` element.z<Relationship xmlns="%s"/>r   IdTypeTarget
TargetMode)r   r   rD   RTMEXTERNAL)rIdreltypetargettarget_moder0   relationships         r   rG   zCT_Relationship.new   sq     +U4[8 ~s#)6*#,,&\3<<8r   c                $    | j                  d      S )zGString held in the ``Id`` attribute of this ``<Relationship>`` element.rT   r;   r.   s    r   rZ   zCT_Relationship.rId   s     xx~r   c                $    | j                  d      S )zIString held in the ``Type`` attribute of this ``<Relationship>`` element.rU   r;   r.   s    r   r[   zCT_Relationship.reltype   s     xxr   c                $    | j                  d      S )zSString held in the ``Target`` attribute of this ``<Relationship>``
        element.rV   r;   r.   s    r   
target_refzCT_Relationship.target_ref   s     xx!!r   c                B    | j                  dt        j                        S )zString held in the ``TargetMode`` attribute of this ``<Relationship>``
        element, either ``Internal`` or ``External``.

        Defaults to ``Internal``.
        rW   )r<   rX   INTERNALr.   s    r   r]   zCT_Relationship.target_mode   s     xxcll33r   N)rZ   strr[   re   r\   re   r]   re   )r1   r2   r3   r4   rH   rX   rd   rG   r5   rZ   r[   rb   r]   r6   r   r   rR   rR      sr     DGLL 	 	       " "
 4 4r   rR   c                  L    e Zd ZdZdddZed	d       Zed        Zed        Z	y)
CT_Relationshipsz>``<Relationships>`` element, the root element in a .rels file.c                    |rt         j                  nt         j                  }t        j	                  ||||      }| j                  |       y)zaAdd a child ``<Relationship>`` element with attributes set according to
        parameter values.N)rX   rY   rd   rR   rG   append)r/   rZ   r[   r\   is_externalr]   r^   s          r   add_relzCT_Relationships.add_rel   s7     '2clls||&**3ML!r   c                 L    dt         d   z  } t        t        t        |             S )z)Return a new ``<Relationships>`` element.z<Relationships xmlns="%s"/>r   )r   r   rg   r   )r0   s    r   rG   zCT_Relationships.new   s$     ,eDk9$in55r   c                6    | j                  t        d            S )zCReturn a list containing all the ``<Relationship>`` child elements.zpr:Relationshipfindallr   r.   s    r   Relationship_lstz!CT_Relationships.Relationship_lst   s     ||B0122r   c                    t        |       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    r   r0   zCT_Relationships.xml   s     "$''r   N)F)rZ   re   r[   re   r\   re   rj   bool)returnrg   )
r1   r2   r3   r4   rk   rH   rG   r5   rp   r0   r6   r   r   rg   rg      sF    H" 6 6
 3 3 ( (r   rg   c                  L    e Zd ZdZd Zd Zed        Zed        Z	ed        Z
y)CT_Typeszh``<Types>`` element, the container element for Default and Override elements in
    [Content_Types].xml.c                R    t         j                  ||      }| j                  |       y)zJAdd a child ``<Default>`` element with attributes set to parameter values.N)r8   rG   ri   )r/   rE   r=   rF   s       r   add_defaultzCT_Types.add_default   s    ..l3Gr   c                R    t         j                  ||      }| j                  |       y)zSAdd a child ``<Override>`` element with attributes set to parameter
        values.N)rJ   rG   ri   )r/   rN   r=   rO   s       r   add_overridezCT_Types.add_override   s      ??8\:Hr   c                6    | j                  t        d            S )Nz
ct:Defaultrn   r.   s    r   defaultszCT_Types.defaults   s    ||B|,--r   c                 4    dt         d   z  } t        |       }|S )z!Return a new ``<Types>`` element.z<Types xmlns="%s"/>r
   )r   r   )r0   typess     r   rG   zCT_Types.new   s      $eDk1#r   c                6    | j                  t        d            S )Nzct:Overridern   r.   s    r   	overrideszCT_Types.overrides   s    ||B}-..r   N)r1   r2   r3   r4   rw   ry   r5   r{   rH   rG   r   r6   r   r   ru   ru      sM    
 . .   / /r   ru   r
   DefaultOverrideTypesr   RelationshipRelationshipsN)r   re   rs   etree._Element)r$   r   )#r4   
__future__r   typingr   lxmlr   docx.opc.constantsr   NSr   rX   ElementNamespaceClassLookupelement_class_lookup	XMLParserr   set_element_class_lookupOPC_CONTENT_TYPESOPC_RELATIONSHIPSOFC_RELATIONSHIPSr   r   r   r%   r*   ElementBaser,   r8   rJ   rR   rg   ru   get_namespacect_namespacepr_namespacer6   r   r   <module>r      s4   #   . > 9u88: eoouM  $ $%9 : 




				/
	%GJ
+e'' 
+ 4$/ $4'4o '4T( (8/ /> $11%+>$Y &Z  W #11%+>.^  0_ r   