o
    P+ irc                     @  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	   tostring	XmlString)r   xml r   ^/home/app/PaddleOCR-VL-test/.venv_paddleocr/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_liner2   )r&   r(   r3   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) r9   r9   r9   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(   r5   r-   r6   r7   r   r=   r   r4   P   s
    zXmlString._parse_lineN)r   r   r   r   )r-   r!   r   r.   )r(   r!   r3   r!   )r(   r!   r   r8   )__name__
__module____qualname____doc__recompilerB   r)   r+   r2   r%   classmethodr4   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)rD   rN   rO   rQ   Zdispatchablekeyvaluer   r   r   __init__`   s   	
zMetaOxmlElement.__init__N)rN   r!   rO   rP   rQ   rR   )rE   rF   rG   rH   r^   r   r   r   r   rM   ]   s    rM   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`   ra   	__class__r   r   r^   u      
zBaseAttribute.__init__element_clsrM   	prop_namer   Nonec                 C  s   || _ || _|   dS z-Add the appropriate methods to `element_cls`.N)_element_cls
_prop_name_add_attr_propertyr&   rj   rk   r   r   r   r[   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setattrrn   ro   r&   	property_r   r   r   rp      s   z BaseAttribute._add_attr_propertyc                 C  s   d| j v r
t| j S | j S )N:)re   r   r&   r   r   r   _clark_name   s   

zBaseAttribute._clark_name'Callable[[BaseOxmlElement], Any | None]c                 C     d S r*   r   ry   r   r   r   rs      s   zBaseAttribute._getter-Callable[[BaseOxmlElement, Any | None], None]c                 C  r|   r*   r   ry   r   r   r   rt      s   zBaseAttribute._setter)r`   r!   ra   rb   rj   rM   rk   r!   r   rl   r   r{   )r   r}   )rE   rF   rG   rH   r^   r[   rp   rr   rz   rs   rt   __classcell__r   r   rg   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 )rU   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!   ra   rb   default0BaseXmlEnum | BaseSimpleType | str | bool | Nonec                   s   t t| || || _d S r*   )rd   rU   r^   _default)r&   r`   ra   r   rg   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.rf   rE   re   ry   r   r   r   
_docstring   s   
zOptionalAttribute._docstringr   r{   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*   )getrz   r   rf   from_xmlr   Zattr_str_valuery   r   r   get_attr_value   s   z1OptionalAttribute._getter.<locals>.get_attr_valueNr   r   r   r   r   rH   r&   r   r   ry   r   rs      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   rz   attribrf   to_xmlsetr   r]   Z	str_valuery   r   r   set_attr_value   s   

z1OptionalAttribute._setter.<locals>.set_attr_valueN)r   r   r]   r   r   r&   r   r   ry   r   rt      s   zOptionalAttribute._setterr*   )r`   r!   ra   rb   r   r   r   r   r   )
rE   rF   rG   rH   r^   rr   r   rs   rt   r   r   r   rg   r   rU      s    	
	rU   c                   @  s8   e Zd ZdZedd ZedddZedd	d
ZdS )rV   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   ry   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   rz   r   re   tagrf   r   r   ry   r   r   r      s   z1RequiredAttribute._getter.<locals>.get_attr_valueNr   r   r   r   ry   r   rs      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)rf   r   
ValueErrorr   rz   r   ry   r   r   r      s   z1RequiredAttribute._setter.<locals>.set_attr_valueN)r   r   r]   r   r   r   r   ry   r   rt      s   zRequiredAttribute._setterN)r   r   r   )rE   rF   rG   rH   rr   r   rs   rt   r   r   r   r   rV      s    	
rV   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                   rc   r*   )rd   r   r^   _nsptagname_successors)r&   r   r   rg   r   r   r^     ri   z_BaseChildElement.__init__rj   rM   rk   r   rl   c                 C  s   || _ || _dS )zFBaseline behavior for adding the appropriate methods to `element_cls`.N)rn   ro   rq   r   r   r   r[     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_namerZ   ru   _insert_method_name)r   r-   Z
new_methodchildr\   r]   Zinsert_methodry   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   rH   _add_to_class_add_method_name)r&   r   r   ry   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   rH   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)rr   rs   ru   rn   ro   rv   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   ry   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   rH   r   r   )r&   r   r   ry   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)ro   rr   _list_getterru   rn   )r&   rk   rw   r   r   r   _add_list_getterI  s   
z"_BaseChildElement._add_list_getterc                 C  
   d| j  S )Nz_add_%sro   ry   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   ry   r   r   	add_childW  s   z6_BaseChildElement._add_public_adder.<locals>.add_childr   Nr   r   )r   rH   r   _public_add_method_name)r&   r   r   ry   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)hasattrrn   ru   )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   ry   r   r   get_child_element|     z4_BaseChildElement._getter.<locals>.get_child_elementz0``<%s>`` child element or |None| if not present.Nr   r   rH   r&   r   r   ry   r   rs   s  s   	z_BaseChildElement._getterc                 C  r   )Nz
_insert_%sr   ry   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   ry   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   ry   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   ry   r   r   r   r     s   
z)_BaseChildElement._public_add_method_namec                 C  r   Nz
_remove_%sr   ry   r   r   r   _remove_method_name  r   z%_BaseChildElement._remove_method_namec                 C  r   )Nz_new_%sr   ry   r   r   r   r     r   z"_BaseChildElement._new_method_namer   )r   r!   r   r   r~   )r   r!   r   r   )r   r   )rE   rF   rG   rH   r^   r[   r   r   r   r   r   r   r   r   r   rr   r   rs   r   r   r   r   r   r   r   r   rg   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   ry   r   r   r   r     s   zChoice.nsptagnamerj   rM   group_prop_namer!   r   r   r   rl   c                 C  s>   || _ || _|| _|   |   |   |   |   dS rm   )rn   _group_prop_namer   r   r   r   r   _add_get_or_change_to_method)r&   rj   r   r   r   r   r   r[     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   ro   _remove_group_method_namer   )r   r   Zremove_group_method
add_methodry   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   rH   r   _get_or_change_to_method_name)r&   r   r   ry   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.rx   r@   r   N)r   index)r&   startr   r   r   ro     s   zChoice._prop_namec                 C  r   )Nzget_or_change_to_%sr   ry   r   r   r   r     r   z$Choice._get_or_change_to_method_namec                 C  r   r   )r   ry   r   r   r   r     r   z Choice._remove_group_method_nameN)rj   rM   r   r!   r   r   r   rl   )rE   rF   rG   rH   rr   r   r[   r   ro   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 )rS   z5Defines a required child element for MetaOxmlElement.r   r!   c                   s   t t| |d d S )Nr   )rd   rS   r^   )r&   r   rg   r   r   r^     s   zOneAndOnlyOne.__init__rj   rM   rk   r   rl   c                   s   t t| || |   dS rm   )rd   rS   r[   r   rq   rg   r   r   r[     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   ry   r   r   r     s   z0OneAndOnlyOne._getter.<locals>.get_child_elementz Required ``<%s>`` child element.Nr   r   r   r   ry   r   rs     s   zOneAndOnlyOne._getter)r   r!   r~   )	rE   rF   rG   rH   r^   r[   rr   rs   r   r   r   rg   r   rS     s    rS   c                      "   e Zd ZdZd
 fdd	Z  ZS )rT   zYDefines a repeating child element for MetaOxmlElement that must appear at least
    once.rj   rM   rk   r!   r   rl   c                   H   t t| || |   |   |   |   |   t|| dS rm   )	rd   rT   r[   r   r   r   r   r   delattrrq   rg   r   r   r[        z OneOrMore.populate_class_membersr~   rE   rF   rG   rH   r[   r   r   r   rg   r   rT     s    rT   c                      r   )rW   z@Defines an optional repeating child element for MetaOxmlElement.rj   rM   rk   r!   r   rl   c                   r   rm   )	rd   rW   r[   r   r   r   r   r   r   rq   rg   r   r   r[     r   z!ZeroOrMore.populate_class_membersr~   r   r   r   rg   r   rW     s    rW   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 )rX   z6Defines an optional child element for MetaOxmlElement.rj   rM   rk   r!   r   rl   c                   sF   t t| || |   |   |   |   |   |   dS rm   )	rd   rX   r[   r   r   r   r   _add_get_or_adder_add_removerrq   rg   r   r   r[     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   ro   r   )r   r   r   ry   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   rH   r   _get_or_add_method_name)r&   r   r   ry   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   ry   r   r   _remove_child<  r   z-ZeroOrOne._add_remover.<locals>._remove_childz#Remove all ``<%s>`` child elements.Nr   )r   rH   r   r   )r&   r   r   ry   r   r   9  s   zZeroOrOne._add_removerc                 C  r   )Nzget_or_add_%sr   ry   r   r   r   r   B  r   z!ZeroOrOne._get_or_add_method_namer~   )
rE   rF   rG   rH   r[   r   r   r   r   r   r   r   rg   r   rX     s    
	rX   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 )rY   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__rj   rM   rk   r!   r   rl   c                   sD   t t| || |   | jD ]}||| j| j q|   dS rm   )rd   rY   r[   _add_choice_getterr   ro   r   _add_group_remover)r&   rj   rk   choicerg   r   r   r[   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)rr   _choice_getterru   rn   ro   rv   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   tagnamery   r   r   _remove_choice_groupb  s   
z@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groupz9Remove the current choice group child element if present.Nr   )rH   r    _remove_choice_group_method_name)r&   r   r   ry   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   ry   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   )rH   )r&   r   r   ry   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   ry   r   r   r   r   w  s   z#ZeroOrOneChoice._member_nsptagnamesc                 C  r   r   r   ry   r   r   r   r   }  r   z0ZeroOrOneChoice._remove_choice_group_method_namer   )r   r   r   r   r~   )rE   rF   rG   rH   r^   r[   r   r   rr   r   r   r   r   r   r   r   rg   r   rY   G  s    

rY   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>)rh   rE   _nsptagidry   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_beforerl   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   ry   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)rd   xpathr   )r&   r  rg   r   r   r    s   zBaseOxmlElement.xpathc                 C  s   t | jS r*   )r   Zfrom_clark_namer   ry   r   r   r   r     s   zBaseOxmlElement._nsptag)r   r!   r   r   )r   r
   r   r!   )r   r!   r   rl   )r   r!   )r  r!   r   r   )rE   rF   rG   rH   r   r   r   r   rr   r   r  r   r   r   r   rg   r   r     s    


r   )	metaclass)r   r
   )-rH   
__future__r   rI   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   rL   typerM   r_   rU   rV   r   r   rS   rT   rW   rX   rY   r   r   r   r   r   <module>   s8    
	;+?/ ":+<