o
    jrc                     @  s  d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZmZmZ dd	lmZ erNdd
lmZ ddlmZ d,ddZG dd deZe
dZG dd de Z!G dd dZ"G dd de"Z#G dd de"Z$G dd dZ%G dd de%Z&G dd  d e%Z'G d!d" d"e%Z(G d#d$ d$e%Z)G d%d& d&e%Z*G d'd( d(e%Z+G d)d* d*eje!d+Z,dS )-z?Enabling declarative definition of lxml custom element classes.    )annotationsN)TYPE_CHECKINGAnyCallableSequenceTypeTypeVar)etree)ElementBase_Element)InvalidXmlError)NamespacePrefixedTagnsmapqn)lazyproperty)BaseXmlEnum)BaseSimpleTypeelementr
   c                 C  s   t j| ddd}t|S )z[Serialize `element` to human-readable XML suitable for tests.

    No XML declaration.
    unicodeT)encodingZpretty_print)r	   Ztostring	XmlString)r   xml r   S/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/docx/oxml/xmlchemy.pyserialize_for_reading   s   r   c                   @  sP   e Zd ZdZedZdddZdd	d
ZdddZ	dddZ
edddZdS )r   z]Provides string comparison override suitable for serialized XML that is useful
    for tests.z)( *</?[\w:]+)(.*?)(/?>)([^<]*</[\w:]+>)?$otherobjectreturnboolc                 C  s\   t |tsdS |  }| }t|t|krdS t||D ]\}}| ||s+ dS qdS )NFT)
isinstancestr
splitlineslenzip_eq_elm_strs)selfr   linesZlines_otherlineZ
line_otherr   r   r   __eq__+   s   
zXmlString.__eq__c                 C  s   |  | S N)r(   )r%   r   r   r   r   __ne__7      zXmlString.__ne__attrsr    	list[str]c                 C  s   |  }| }t|S )zReturn a sequence of attribute strings parsed from `attrs`.

        Each attribute string is stripped of whitespace on both ends.
        )stripsplitsorted)r%   r,   Zattr_lstr   r   r   	_attr_seq:   s   zXmlString._attr_seqr'   line_2c                 C  s\   |  |\}}}}|  |\}}}	}
||krdS | || |kr$dS ||	kr*dS ||
kS )zZReturn True if the element in `line_2` is XML equivalent to the element in
        `line`.F)_parse_liner1   )r%   r'   r2   frontr,   closetextZfront_2Zattrs_2Zclose_2Ztext_2r   r   r   r$   C   s   zXmlString._eq_elm_strstuple[str, str, str, str]c                   sD   | j |  du rdS  fddtddD \}}}}||||fS )zI(front, attrs, close, text) 4-tuple result of parsing XML element `line`.N) r8   r8   r8   c                   s   g | ]}  |qS r   )group).0nmatchr   r   
<listcomp>V   s    z)XmlString._parse_line.<locals>.<listcomp>      )_xml_elm_line_pattr=   range)clsr'   r4   r,   r5   r6   r   r<   r   r3   P   s
    zXmlString._parse_lineN)r   r   r   r   )r,   r    r   r-   )r'   r    r2   r    )r'   r    r   r7   )__name__
__module____qualname____doc__recompilerA   r(   r*   r1   r$   classmethodr3   r   r   r   r   r      s    
	



	r   _Tc                   @  s   e Zd ZdZddd	Zd
S )MetaOxmlElementzMetaclass for BaseOxmlElement.clsnamer    basestuple[type, ...]	namespacedict[str, Any]c                 C  s>   t ttttttf}| D ]\}}t||r|	| | qd S r)   )
OneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoiceitemsr   populate_class_members)rC   rM   rN   rP   Zdispatchablekeyvaluer   r   r   __init__`   s   	
zMetaOxmlElement.__init__N)rM   r    rN   rO   rP   rQ   )rD   rE   rF   rG   r]   r   r   r   r   rL   ]   s    rL   c                      s\   e Zd ZdZd fddZdddZdd Zedd ZedddZ	edddZ
  ZS )BaseAttributezZBase class for OptionalAttribute and RequiredAttribute.

    Provides common methods.
    	attr_namer    simple_type(Type[BaseXmlEnum] | Type[BaseSimpleType]c                      t t|   || _|| _d S r)   )superr^   r]   
_attr_name_simple_type)r%   r_   r`   	__class__r   r   r]   u      
zBaseAttribute.__init__element_clsrL   	prop_namer   Nonec                 C  s   || _ || _|   dS z-Add the appropriate methods to `element_cls`.N)_element_cls
_prop_name_add_attr_propertyr%   ri   rj   r   r   r   rZ   z   s   z$BaseAttribute.populate_class_membersc                 C  s$   t | j| jd}t| j| j| dS )zAdd a read/write `.{prop_name}` property to the element class.

        The property returns the interpreted value of this attribute on access and
        changes the attribute value to its ST_* counterpart on assignment.
        N)property_getter_settersetattrrm   rn   r%   	property_r   r   r   ro      s   z BaseAttribute._add_attr_propertyc                 C  s   d| j v r
t| j S | j S )N:)rd   r   r%   r   r   r   _clark_name   s   

zBaseAttribute._clark_name'Callable[[BaseOxmlElement], Any | None]c                 C     d S r)   r   rx   r   r   r   rr      s   zBaseAttribute._getter-Callable[[BaseOxmlElement, Any | None], None]c                 C  r{   r)   r   rx   r   r   r   rs      s   zBaseAttribute._setter)r_   r    r`   ra   ri   rL   rj   r    r   rk   r   rz   )r   r|   )rD   rE   rF   rG   r]   rZ   ro   rq   ry   rr   rs   __classcell__r   r   rf   r   r^   o   s    


r^   c                      sN   e Zd ZdZ	dd fd	d
Zedd ZedddZedddZ  Z	S )rT   a  Defines an optional attribute on a custom element class.

    An optional attribute returns a default value when not present for reading. When
    assigned |None|, the attribute is removed, but still returns the default value when
    one is specified.
    Nr_   r    r`   ra   default0BaseXmlEnum | BaseSimpleType | str | bool | Nonec                   s   t t| || || _d S r)   )rc   rT   r]   _default)r%   r_   r`   r   rf   r   r   r]      s   
zOptionalAttribute.__init__c                 C  s   | j j d| j dS )z;String to use as `__doc__` attribute of attribute property.z type-converted value of ``z`` attribute, or |None| (or specified default value) if not present. Assigning the default value causes the attribute to be removed from the element.re   rD   rd   rx   r   r   r   
_docstring   s   
zOptionalAttribute._docstringr   rz   c                      d fdd} j |_|S )	zJFunction suitable for `__get__()` method on attribute property descriptor.objBaseOxmlElementr   
Any | Nonec                   s&   |   j}|d u r jS  j|S r)   )getry   r   re   from_xmlr   Zattr_str_valuerx   r   r   get_attr_value   s   z1OptionalAttribute._getter.<locals>.get_attr_valueNr   r   r   r   r   rG   r%   r   r   rx   r   rr      s   zOptionalAttribute._getter&Callable[[BaseOxmlElement, Any], None]c                      d fdd}|S )	zJFunction suitable for `__set__()` method on attribute property descriptor.r   r   r\   r   c                   sl   |d u s	| j kr j| jv r| j j= d S  j|}|d u r- j| jv r+| j j= d S |  j| d S r)   )r   ry   Zattribre   to_xmlsetr   r\   Z	str_valuerx   r   r   set_attr_value   s   

z1OptionalAttribute._setter.<locals>.set_attr_valueN)r   r   r\   r   r   r%   r   r   rx   r   rs      s   zOptionalAttribute._setterr)   )r_   r    r`   ra   r   r   r~   r   r   )
rD   rE   rF   rG   r]   rq   r   rr   rs   r   r   r   rf   r   rT      s    	
	rT   c                   @  s8   e Zd ZdZedd ZedddZedd	d
ZdS )rU   a  Defines a required attribute on a custom element class.

    A required attribute is assumed to be present for reading, so does not have a
    default value; its actual value is always used. If missing on read, an
    |InvalidXmlError| is raised. It also does not remove the attribute if |None| is
    assigned. Assigning |None| raises |TypeError| or |ValueError|, depending on the
    simple type of the attribute.
    c                 C  s   d| j j| jf S )zaReturn the string to use as the ``__doc__`` attribute of the property for
        this attribute.z,%s type-converted value of ``%s`` attribute.r   rx   r   r   r   r      s   zRequiredAttribute._docstringr    Callable[[BaseOxmlElement], Any]c                   r   )	zDfunction object suitable for "get" side of attr property descriptor.r   r   r   r   c                   s4   |   j}|d u rtd j| jf  j|S )Nz1required '%s' attribute not present on element %s)r   ry   r   rd   tagre   r   r   rx   r   r   r      s   z1RequiredAttribute._getter.<locals>.get_attr_valueNr   r   r   r   rx   r   rr      s   zRequiredAttribute._getterr   c                   r   )	zIfunction object suitable for "set" side of attribute property descriptor.r   r   r\   r   c                   s6    j |}|d u rtd| d|  j| d S )Nzcannot assign z to this required attribute)re   r   
ValueErrorr   ry   r   rx   r   r   r      s   z1RequiredAttribute._setter.<locals>.set_attr_valueN)r   r   r\   r   r   r   r   rx   r   rs      s   zRequiredAttribute._setterN)r   r   r   )rD   rE   rF   rG   rq   r   rr   rs   r   r   r   r   rU      s    	
rU   c                      s   e Zd ZdZd2d3 fddZd4ddZdd Zdd Zdd Zdd Z	dd Z
edd Zdd Zd5d!d"Zed6d$d%Zed&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Z  ZS )7_BaseChildElementzBase class for the child-element classes.

    The child-element sub-classes correspond to varying cardinalities, such as ZeroOrOne
    and ZeroOrMore.
    r   
nsptagnamer    
successorstuple[str, ...]c                   rb   r)   )rc   r   r]   _nsptagname_successors)r%   r   r   rf   r   r   r]     rh   z_BaseChildElement.__init__ri   rL   rj   r   rk   c                 C  s   || _ || _dS )zFBaseline behavior for adding the appropriate methods to `element_cls`.N)rm   rn   rp   r   r   r   rZ     s   
z(_BaseChildElement.populate_class_membersc                   s,   d	 fdd}d j  |_  j| dS )
zGAdd an ``_add_x()`` method to the element class for this child element.r   r   r,   r   c                   sH   t |  j}| }| D ]
\}}t||| qt |  j}|| |S r)   )getattr_new_method_namerY   rt   _insert_method_name)r   r,   Z
new_methodchildr[   r\   Zinsert_methodrx   r   r   
_add_child  s   z0_BaseChildElement._add_adder.<locals>._add_childSAdd a new ``<%s>`` child element unconditionally, inserted in the correct sequence.N)r   r   r,   r   )r   rG   _add_to_class_add_method_name)r%   r   r   rx   r   
_add_adder  s   
z_BaseChildElement._add_adderc                 C  s$   | j }d| j |_| | j| dS )zAdd a ``_new_{prop_name}()`` method to the element class that creates a new,
        empty element of the correct type, having no attributes.zYReturn a "loose", newly created ``<%s>`` element having no attributes, text, or children.N)_creatorr   rG   r   r   )r%   Zcreatorr   r   r   _add_creator+  s   z_BaseChildElement._add_creatorc                 C  "   t | jdd}t| j| j| dS )z]Add a read-only ``{prop_name}`` property to the element class for this child
        element.N)rq   rr   rt   rm   rn   ru   r   r   r   _add_getter5     z_BaseChildElement._add_getterc                   s,   d fdd}d j  |_  j| dS )	zJAdd an ``_insert_x()`` method to the element class for this child element.r   r   r   c                   s   | j |g jR   |S r)   )insert_element_beforer   r   r   rx   r   r   _insert_child?  s   z6_BaseChildElement._add_inserter.<locals>._insert_childzYReturn the passed ``<%s>`` element after inserting it as a child in the correct sequence.N)r   r   r   r   )r   rG   r   r   )r%   r   r   rx   r   _add_inserter<  s   z_BaseChildElement._add_inserterc                 C  s*   d| j  }t| jdd}t| j|| dS )zAdd a read-only ``{prop_name}_lst`` property to the element class to retrieve
        a list of child elements matching this type.z%s_lstN)rn   rq   _list_getterrt   rm   )r%   rj   rv   r   r   r   _add_list_getterI  s   
z"_BaseChildElement._add_list_getterc                 C  
   d| j  S )Nz_add_%srn   rx   r   r   r   r   P     
z"_BaseChildElement._add_method_namec                   ,   d fdd}d j  |_  j| dS )z<Add a public ``add_x()`` method to the parent element class.r   r   c                   s   t |  j}| }|S r)   )r   r   )r   Zprivate_add_methodr   rx   r   r   	add_childW  s   z6_BaseChildElement._add_public_adder.<locals>.add_childr   Nr   r   )r   rG   r   _public_add_method_name)r%   r   r   rx   r   _add_public_adderT  s   z#_BaseChildElement._add_public_addernamemethodCallable[..., Any]c                 C  s"   t | j|rdS t| j|| dS )zbAdd `method` to the target class as `name`, unless `name` is already defined
        on the class.N)hasattrrm   rt   )r%   r   r   r   r   r   r   b  s   z_BaseChildElement._add_to_class,Callable[[BaseOxmlElement], BaseOxmlElement]c                   s    ddl m  d fdd}|S )	zHCallable that creates an empty element of the right type, with no attrs.r   )OxmlElementr   r   c                   s
    j S r)   r   r   r   r%   r   r   new_child_elementn  s   
z5_BaseChildElement._creator.<locals>.new_child_elementNr   )Zdocx.oxml.parserr   )r%   r   r   r   r   r   i  s   z_BaseChildElement._creatorc                      d fdd}d j  |_|S )zReturn a function object suitable for the "get" side of the property
        descriptor.

        This default getter returns the child element with matching tag name or |None|
        if not present.
        r   r   c                      |  t jS r)   )findr   r   r   rx   r   r   get_child_element|     z4_BaseChildElement._getter.<locals>.get_child_elementz0``<%s>`` child element or |None| if not present.Nr   r   rG   r%   r   r   rx   r   rr   s  s   	z_BaseChildElement._getterc                 C  r   )Nz
_insert_%sr   rx   r   r   r   r     r   z%_BaseChildElement._insert_method_namec                   r   )z[Return a function object suitable for the "get" side of a list property
        descriptor.r   r   c                   r   r)   )findallr   r   r   rx   r   r   get_child_element_list  r   z>_BaseChildElement._list_getter.<locals>.get_child_element_listzPA list containing each of the ``<%s>`` child elements, in the order they appear.Nr   r   )r%   r   r   rx   r   r     s   z_BaseChildElement._list_getterc                 C  r   )a
  add_childElement() is public API for a repeating element, allowing new
        elements to be added to the sequence.

        May be overridden to provide a friendlier API to clients having domain
        appropriate parameter names for required attributes.
        zadd_%sr   rx   r   r   r   r     s   
z)_BaseChildElement._public_add_method_namec                 C  r   Nz
_remove_%sr   rx   r   r   r   _remove_method_name  r   z%_BaseChildElement._remove_method_namec                 C  r   )Nz_new_%sr   rx   r   r   r   r     r   z"_BaseChildElement._new_method_namer   )r   r    r   r   r}   )r   r    r   r   )r   r   )rD   rE   rF   rG   r]   rZ   r   r   r   r   r   r   r   r   r   rq   r   rr   r   r   r   r   r   r   r   r   rf   r   r     s6    



	



	
r   c                   @  sR   e Zd ZdZedd ZdddZdd Zedd Ze	dd Z
e	dd ZdS )ChoicezVDefines a child element belonging to a group, only one of which may appear as a child.c                 C  s   | j S r)   r   rx   r   r   r   r     s   zChoice.nsptagnameri   rL   group_prop_namer    r   r   r   rk   c                 C  s>   || _ || _|| _|   |   |   |   |   dS rl   )rm   _group_prop_namer   r   r   r   r   _add_get_or_change_to_method)r%   ri   r   r   r   r   r   rZ     s   zChoice.populate_class_membersc                   r   )zZAdd a ``get_or_change_to_x()`` method to the element class for this child
        element.r   r   c                   s@   t |  j}|d ur|S t |  j}|  t |  j}| }|S r)   )r   rn   _remove_group_method_namer   )r   r   Zremove_group_method
add_methodrx   r   r   get_or_change_to_child  s   zCChoice._add_get_or_change_to_method.<locals>.get_or_change_to_childzFReturn the ``<%s>`` child, replacing any other group element if found.Nr   )r   rG   r   _get_or_change_to_method_name)r%   r   r   rx   r   r     s
   z#Choice._add_get_or_change_to_methodc                 C  s,   d| j v r| j dd nd}| j |d S )zDProperty name computed from tag name, e.g. a:schemeClr -> schemeClr.rw   r?   r   N)r   index)r%   startr   r   r   rn     s   zChoice._prop_namec                 C  r   )Nzget_or_change_to_%sr   rx   r   r   r   r     r   z$Choice._get_or_change_to_method_namec                 C  r   r   )r   rx   r   r   r   r     r   z Choice._remove_group_method_nameN)ri   rL   r   r    r   r   r   rk   )rD   rE   rF   rG   rq   r   rZ   r   rn   r   r   r   r   r   r   r   r     s    



r   c                      s<   e Zd ZdZd fddZd fddZedd Z  ZS )rR   z5Defines a required child element for MetaOxmlElement.r   r    c                   s   t t| |d d S )Nr   )rc   rR   r]   )r%   r   rf   r   r   r]     s   zOneAndOnlyOne.__init__ri   rL   rj   r   rk   c                   s   t t| || |   dS rl   )rc   rR   rZ   r   rp   rf   r   r   rZ     s   z$OneAndOnlyOne.populate_class_membersc                   r   )XReturn a function object suitable for the "get" side of the property
        descriptor.r   r   c                   s*   |  t j}|d u rtd j |S )Nz+required ``<%s>`` child element not present)r   r   r   r   r   rx   r   r   r     s   z0OneAndOnlyOne._getter.<locals>.get_child_elementz Required ``<%s>`` child element.Nr   r   r   r   rx   r   rr     s   zOneAndOnlyOne._getter)r   r    r}   )	rD   rE   rF   rG   r]   rZ   rq   rr   r   r   r   rf   r   rR     s    rR   c                      "   e Zd ZdZd
 fdd	Z  ZS )rS   zYDefines a repeating child element for MetaOxmlElement that must appear at least
    once.ri   rL   rj   r    r   rk   c                   H   t t| || |   |   |   |   |   t|| dS rl   )	rc   rS   rZ   r   r   r   r   r   delattrrp   rf   r   r   rZ        z OneOrMore.populate_class_membersr}   rD   rE   rF   rG   rZ   r   r   r   rf   r   rS     s    rS   c                      r   )rV   z@Defines an optional repeating child element for MetaOxmlElement.ri   rL   rj   r    r   rk   c                   r   rl   )	rc   rV   rZ   r   r   r   r   r   r   rp   rf   r   r   rZ     r   z!ZeroOrMore.populate_class_membersr}   r   r   r   rf   r   rV     s    rV   c                      s>   e Zd ZdZd fdd	Zd
d Zdd Zedd Z  Z	S )rW   z6Defines an optional child element for MetaOxmlElement.ri   rL   rj   r    r   rk   c                   sF   t t| || |   |   |   |   |   |   dS rl   )	rc   rW   rZ   r   r   r   r   _add_get_or_adder_add_removerrp   rf   r   r   rZ     s   z ZeroOrOne.populate_class_membersc                   r   )zTAdd a ``get_or_add_x()`` method to the element class for this child
        element.r   r   c                   s*   t |  j}|d u rt |  j}| }|S r)   )r   rn   r   )r   r   r   rx   r   r   get_or_add_child-  s
   z5ZeroOrOne._add_get_or_adder.<locals>.get_or_add_childz>Return the ``<%s>`` child element, newly added if not present.Nr   )r   rG   r   _get_or_add_method_name)r%   r   r   rx   r   r   )  s
   zZeroOrOne._add_get_or_adderc                   r   )zIAdd a ``_remove_x()`` method to the element class for this child element.r   r   c                   s   |   j d S r)   )
remove_allr   r   rx   r   r   _remove_child<  r   z-ZeroOrOne._add_remover.<locals>._remove_childz#Remove all ``<%s>`` child elements.Nr   )r   rG   r   r   )r%   r   r   rx   r   r   9  s   zZeroOrOne._add_removerc                 C  r   )Nzget_or_add_%sr   rx   r   r   r   r   B  r   z!ZeroOrOne._get_or_add_method_namer}   )
rD   rE   rF   rG   rZ   r   r   r   r   r   r   r   rf   r   rW     s    
	rW   c                      sb   e Zd ZdZddddZd fddZdd Zdd Zedd Z	e
dd Ze
dd Z  ZS )rX   zeCorrespondes to an ``EG_*`` element group where at most one of its members may
    appear as a child.r   choicesSequence[Choice]r   r   c                 C  s   || _ || _d S r)   )_choicesr   )r%   r   r   r   r   r   r]   K  s   
zZeroOrOneChoice.__init__ri   rL   rj   r    r   rk   c                   sD   t t| || |   | jD ]}||| j| j q|   dS rl   )rc   rX   rZ   _add_choice_getterr   rn   r   _add_group_remover)r%   ri   rj   choicerf   r   r   rZ   O  s
   
z&ZeroOrOneChoice.populate_class_membersc                 C  r   )zAdd a read-only ``{prop_name}`` property to the element class that returns
        the present member of this group, or |None| if none are present.N)rq   _choice_getterrt   rm   rn   ru   r   r   r   r   W  r   z"ZeroOrOneChoice._add_choice_getterc                   s&   d fdd}d|_   j| dS )zSAdd a ``_remove_eg_x()`` method to the element class for this choice
        group.r   r   c                   s    j D ]}| | qd S r)   )_member_nsptagnamesr   )r   tagnamerx   r   r   _remove_choice_groupb  s   
z@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groupz9Remove the current choice group child element if present.Nr   )rG   r    _remove_choice_group_method_name)r%   r   r   rx   r   r   ^  s   z"ZeroOrOneChoice._add_group_removerc                   s   d fdd}d|_ |S )r   r   r   c                   s   | j  j S r)   )first_child_found_inr   r   rx   r   r   get_group_member_elementn  r+   z@ZeroOrOneChoice._choice_getter.<locals>.get_group_member_elementzbReturn the child element belonging to this element group, or |None| if no member child is present.Nr   )rG   )r%   r   r   rx   r   r   i  s   zZeroOrOneChoice._choice_getterc                 C  s   dd | j D S )zjSequence of namespace-prefixed tagnames, one for each of the member elements
        of this choice group.c                 S  s   g | ]}|j qS r   )r   )r:   r   r   r   r   r>   {  s    z7ZeroOrOneChoice._member_nsptagnames.<locals>.<listcomp>)r   rx   r   r   r   r   w  s   z#ZeroOrOneChoice._member_nsptagnamesc                 C  r   r   r   rx   r   r   r   r   }  r   z0ZeroOrOneChoice._remove_choice_group_method_namer   )r   r   r   r   r}   )rD   rE   rF   rG   r]   rZ   r   r   rq   r   r   r   r   r   r   r   rf   r   rX   G  s    

rX   c                      sd   e Zd ZdZdd Zddd	ZdddZdddZedddZ	d fddZ
edddZ  ZS )r   zvEffective base class for all custom element classes.

    Adds standardized behavior to all classes in one place.
    c                 C  s   d| j j| jt| f S )Nz<%s '<%s>' at 0x%0x>)rg   rD   _nsptagidrx   r   r   r   __repr__  s
   zBaseOxmlElement.__repr__tagnamesr    r   _Element | Nonec                 G  s,   |D ]}|  t|}|dur|  S qdS )z9First child with tag in `tagnames`, or None if not found.N)r   r   )r%   r   r   r   r   r   r   r     s   z$BaseOxmlElement.first_child_found_inelmr
   c                 G  s.   | j | }|d ur|| |S | | |S r)   )r   Zaddpreviousappend)r%   r   r   	successorr   r   r   r     s   


z%BaseOxmlElement.insert_element_beforerk   c                 G  s0   |D ]}|  t|}|D ]}| | qqdS )z>Remove child elements with tagname (e.g. "a:p") in `tagnames`.N)r   r   remove)r%   r   r   Zmatchingr   r   r   r   r     s   zBaseOxmlElement.remove_allc                 C  s   t | S )zXML string for this element, suitable for testing purposes.

        Pretty printed for readability and without an XML declaration at the top.
        )r   rx   r   r   r   r     s   zBaseOxmlElement.xml	xpath_strr   c                   s   t  j|tdS )zOverride of `lxml` _Element.xpath() method.

        Provides standard Open XML namespace mapping (`nsmap`) in centralized location.
        )
namespaces)rc   xpathr   )r%   r   rf   r   r   r    s   zBaseOxmlElement.xpathc                 C  s   t | jS r)   )r   Zfrom_clark_namer   rx   r   r   r   r     s   zBaseOxmlElement._nsptag)r   r    r   r   )r   r
   r   r    )r   r    r   rk   )r   r    )r   r    r   r   )rD   rE   rF   rG   r   r   r   r   rq   r   r  r   r   r   r   rf   r   r     s    


r   )	metaclass)r   r
   )-rG   
__future__r   rH   typingr   r   r   r   r   r   Zlxmlr	   Z
lxml.etreer
   r   Zdocx.oxml.exceptionsr   Zdocx.oxml.nsr   r   r   Zdocx.sharedr   Zdocx.enum.baser   Zdocx.oxml.simpletypesr   r   r    r   rK   typerL   r^   rT   rU   r   r   rR   rS   rV   rW   rX   r   r   r   r   r   <module>   s8    
	;+?/ ":+<