a
    ]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rdd
lmZ ddlmZ d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)BaseSimpleTyper
   )elementc                 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   N/var/www/html/assistant/venv/lib/python3.9/site-packages/docx/oxml/xmlchemy.pyserialize_for_reading   s    r   c                   @  sn   e Zd ZdZedZdddddZddddd	Zd
ddddZ	d
d
dddZ
ed
ddddZdS )r   z]Provides string comparison override suitable for serialized XML that is useful
    for tests.z)( *</?[\w:]+)(.*?)(/?>)([^<]*</[\w:]+>)?$objectbool)otherreturnc                 C  s\   t |tsdS |  }| }t|t|kr2d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   s    zXmlString.__ne__r    z	list[str])attrsr   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_seq)r'   line_2c                 C  s\   |  |\}}}}|  |\}}}	}
||kr0dS | || |krHdS ||	krTdS ||
kS )zZReturn True if the element in `line_2` is XML equivalent to the element in
        `line`.F)_parse_liner/   )r%   r'   r0   frontr+   closetextZfront_2Zattrs_2Zclose_2Ztext_2r   r   r   r$   C   s    zXmlString._eq_elm_strsztuple[str, str, str, str])r'   r   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) r5   r5   r5   c                   s   g | ]}  |qS r   )group).0nmatchr   r   
<listcomp>V       z)XmlString._parse_line.<locals>.<listcomp>      )_xml_elm_line_pattr:   range)clsr'   r2   r+   r3   r4   r   r9   r   r1   P   s
     zXmlString._parse_lineN)__name__
__module____qualname____doc__recompiler?   r(   r*   r/   r$   classmethodr1   r   r   r   r   r      s   	
	r   _Tc                   @  s"   e Zd ZdZddddddZdS )	MetaOxmlElementzMetaclass for BaseOxmlElement.r    ztuple[type, ...]zdict[str, Any])clsnamebases	namespacec                 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)rA   rK   rL   rM   Zdispatchablekeyvaluer   r   r   __init__`   s    	
zMetaOxmlElement.__init__N)rB   rC   rD   rE   rY   r   r   r   r   rJ   ]   s   rJ   c                      sr   e Zd ZdZddd fddZdddd	d
dZdd Zedd ZeddddZ	eddddZ
  ZS )BaseAttributezZBase class for OptionalAttribute and RequiredAttribute.

    Provides common methods.
    r    (Type[BaseXmlEnum] | Type[BaseSimpleType])	attr_namesimple_typec                   s   t t|   || _|| _d S r)   )superrZ   rY   
_attr_name_simple_type)r%   r\   r]   	__class__r   r   rY   u   s    zBaseAttribute.__init__rJ   Noneelement_cls	prop_namer   c                 C  s   || _ || _|   dS z-Add the appropriate methods to `element_cls`.N)_element_cls
_prop_name_add_attr_propertyr%   re   rf   r   r   r   rV   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setattrrh   ri   r%   	property_r   r   r   rj      s    z BaseAttribute._add_attr_propertyc                 C  s   d| j v rt| j S | j S )N:)r_   r   r%   r   r   r   _clark_name   s    

zBaseAttribute._clark_name'Callable[[BaseOxmlElement], Any | None]r   c                 C  s   d S r)   r   rs   r   r   r   rm      s    zBaseAttribute._getterz-Callable[[BaseOxmlElement, Any | None], None]c                 C  s   d S r)   r   rs   r   r   r   rn      s    zBaseAttribute._setter)rB   rC   rD   rE   rY   rV   rj   rl   rt   rm   rn   __classcell__r   r   ra   r   rZ   o   s   

rZ   c                      s\   e Zd ZdZddddd fddZed	d
 ZeddddZeddddZ  Z	S )rP   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[   z0BaseXmlEnum | BaseSimpleType | str | bool | None)r\   r]   defaultc                   s   t t| || || _d S r)   )r^   rP   rY   _default)r%   r\   r]   rx   ra   r   r   rY      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.r`   rB   r_   rs   r   r   r   
_docstring   s    
zOptionalAttribute._docstringru   rv   c                   s    ddd fdd} j |_|S )zJFunction suitable for `__get__()` method on attribute property descriptor.BaseOxmlElement
Any | Noneobjr   c                   s&   |   j}|d u r jS  j|S r)   )getrt   ry   r`   from_xmlr   Zattr_str_valuers   r   r   get_attr_value   s    z1OptionalAttribute._getter.<locals>.get_attr_valuer{   rE   r%   r   r   rs   r   rm      s    zOptionalAttribute._getter&Callable[[BaseOxmlElement, Any], None]c                   s   ddd fdd}|S )zJFunction suitable for `__set__()` method on attribute property descriptor.r|   r}   r   rX   c                   sl   |d u s| j kr, j| jv r(| j j= d S  j|}|d u rZ j| jv rV| j j= d S |  j| d S r)   )ry   rt   Zattribr`   to_xmlsetr   rX   Z	str_valuers   r   r   set_attr_value   s    

z1OptionalAttribute._setter.<locals>.set_attr_valuer   r%   r   r   rs   r   rn      s    zOptionalAttribute._setter)N)
rB   rC   rD   rE   rY   rl   r{   rm   rn   rw   r   r   ra   r   rP      s    	
	rP   c                   @  s@   e Zd ZdZedd ZeddddZeddd	d
ZdS )rQ   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.rz   rs   r   r   r   r{      s    zRequiredAttribute._docstringz Callable[[BaseOxmlElement], Any]rv   c                   s    ddd fdd} j |_|S )zDfunction object suitable for "get" side of attr property descriptor.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   rt   r   r_   tagr`   r   r   rs   r   r   r      s    z1RequiredAttribute._getter.<locals>.get_attr_valuer   r   r   rs   r   rm      s    zRequiredAttribute._getterr   c                   s   ddd fdd}|S )zIfunction object suitable for "set" side of attribute property descriptor.r|   r   r   c                   s6    j |}|d u r$td| d|  j| d S )Nzcannot assign z to this required attribute)r`   r   
ValueErrorr   rt   r   rs   r   r   r      s    z1RequiredAttribute._setter.<locals>.set_attr_valuer   r   r   rs   r   rn      s    zRequiredAttribute._setterN)rB   rC   rD   rE   rl   r{   rm   rn   r   r   r   r   rQ      s   	
rQ   c                      s   e Zd ZdZd/ddd fddZddd	d
ddZdd Zdd Zdd Zdd Z	dd Z
edd Zdd ZdddddZedd d!d"Zed#d$ Zed%d& Zed'd( Zed)d* Zed+d, Zed-d. Z  ZS )0_BaseChildElementzBase class for the child-element classes.

    The child-element sub-classes correspond to varying cardinalities, such as ZeroOrOne
    and ZeroOrMore.
    r   r    tuple[str, ...])
nsptagname
successorsc                   s   t t|   || _|| _d S r)   )r^   r   rY   _nsptagname_successors)r%   r   r   ra   r   r   rY     s    z_BaseChildElement.__init__rJ   rc   rd   c                 C  s   || _ || _dS )zFBaseline behavior for adding the appropriate methods to `element_cls`.N)rh   ri   rk   r   r   r   rV     s    z(_BaseChildElement.populate_class_membersc                   s2   dd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_namerU   ro   _insert_method_name)r   r+   Z
new_methodchildrW   rX   Zinsert_methodrs   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   rE   _add_to_class_add_method_name)r%   r   r   rs   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   rE   r   r   )r%   Zcreatorr   r   r   _add_creator+  s    z_BaseChildElement._add_creatorc                 C  s"   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)rl   rm   ro   rh   ri   rp   r   r   r   _add_getter5  s    z_BaseChildElement._add_getterc                   s2   dd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   rs   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   rE   r   r   )r%   r   r   rs   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)ri   rl   _list_getterro   rh   )r%   rf   rq   r   r   r   _add_list_getterI  s    
z"_BaseChildElement._add_list_getterc                 C  s
   d| j  S )Nz_add_%sri   rs   r   r   r   r   P  s    z"_BaseChildElement._add_method_namec                   s0   d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   rs   r   r   	add_childW  s    z6_BaseChildElement._add_public_adder.<locals>.add_childr   N)r   rE   r   _public_add_method_name)r%   r   r   rs   r   _add_public_adderT  s    z#_BaseChildElement._add_public_adderzCallable[..., Any])namemethodc                 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)hasattrrh   ro   )r%   r   r   r   r   r   r   b  s    z_BaseChildElement._add_to_classz,Callable[[BaseOxmlElement], BaseOxmlElement]rv   c                   s$   ddl m  d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_element)Zdocx.oxml.parserr   )r%   r   r   r   r   r   i  s    z_BaseChildElement._creatorc                   s"   d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                   s   |  t jS r)   )findr   r   r   rs   r   r   get_child_element|  s    z4_BaseChildElement._getter.<locals>.get_child_elementz0``<%s>`` child element or |None| if not present.r   rE   r%   r   r   rs   r   rm   s  s    	z_BaseChildElement._getterc                 C  s
   d| j  S )Nz
_insert_%sr   rs   r   r   r   r     s    z%_BaseChildElement._insert_method_namec                   s"   dd fdd}d j  |_|S )z[Return a function object suitable for the "get" side of a list property
        descriptor.r|   r   c                   s   |  t jS r)   )findallr   r   r   rs   r   r   get_child_element_list  s    z>_BaseChildElement._list_getter.<locals>.get_child_element_listzPA list containing each of the ``<%s>`` child elements, in the order they appear.r   )r%   r   r   rs   r   r     s    z_BaseChildElement._list_getterc                 C  s
   d| j  S )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   rs   r   r   r   r     s    z)_BaseChildElement._public_add_method_namec                 C  s
   d| j  S Nz
_remove_%sr   rs   r   r   r   _remove_method_name  s    z%_BaseChildElement._remove_method_namec                 C  s
   d| j  S )Nz_new_%sr   rs   r   r   r   r     s    z"_BaseChildElement._new_method_name)r   )rB   rC   rD   rE   rY   rV   r   r   r   r   r   r   r   r   r   rl   r   rm   r   r   r   r   r   rw   r   r   ra   r   r     s4   

	



	
r   c                   @  s\   e Zd ZdZedd Zdddd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   rs   r   r   r   r     s    zChoice.nsptagnamerJ   r    r   rc   )re   group_prop_namer   r   c                 C  s>   || _ || _|| _|   |   |   |   |   dS rg   )rh   _group_prop_namer   r   r   r   r   _add_get_or_change_to_method)r%   re   r   r   r   r   r   rV     s    zChoice.populate_class_membersc                   s0   dd fdd}d j  |_  j| dS )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   ri   _remove_group_method_namer   )r   r   Zremove_group_method
add_methodrs   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.N)r   rE   r   _get_or_change_to_method_name)r%   r   r   rs   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.rr   r=   r   N)r   index)r%   startr   r   r   ri     s    zChoice._prop_namec                 C  s
   d| j  S )Nzget_or_change_to_%sr   rs   r   r   r   r     s    z$Choice._get_or_change_to_method_namec                 C  s
   d| j  S r   )r   rs   r   r   r   r     s    z Choice._remove_group_method_nameN)rB   rC   rD   rE   rl   r   rV   r   ri   r   r   r   r   r   r   r   r     s   


r   c                      sH   e Zd ZdZdd fddZdddd fd	d
Zedd Z  ZS )rN   z5Defines a required child element for MetaOxmlElement.r    r   c                   s   t t| |d d S )Nr   )r^   rN   rY   )r%   r   ra   r   r   rY     s    zOneAndOnlyOne.__init__rJ   rc   rd   c                   s   t t| || |   dS rg   )r^   rN   rV   r   rk   ra   r   r   rV     s    z$OneAndOnlyOne.populate_class_membersc                   s"   dd fdd}d j  |_|S )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   rs   r   r   r     s    z0OneAndOnlyOne._getter.<locals>.get_child_elementz Required ``<%s>`` child element.r   r   r   rs   r   rm     s    zOneAndOnlyOne._getter)	rB   rC   rD   rE   rY   rV   rl   rm   rw   r   r   ra   r   rN     s
   rN   c                      s*   e Zd ZdZdddd fddZ  ZS )rO   zYDefines a repeating child element for MetaOxmlElement that must appear at least
    once.rJ   r    rc   rd   c                   sH   t t| || |   |   |   |   |   t|| dS rg   )	r^   rO   rV   r   r   r   r   r   delattrrk   ra   r   r   rV     s    z OneOrMore.populate_class_membersrB   rC   rD   rE   rV   rw   r   r   ra   r   rO     s   rO   c                      s*   e Zd ZdZdddd fddZ  ZS )rR   z@Defines an optional repeating child element for MetaOxmlElement.rJ   r    rc   rd   c                   sH   t t| || |   |   |   |   |   t|| dS rg   )	r^   rR   rV   r   r   r   r   r   r   rk   ra   r   r   rV     s    z!ZeroOrMore.populate_class_membersr   r   r   ra   r   rR     s   rR   c                      sF   e Zd ZdZdddd fddZdd	 Zd
d Zedd Z  Z	S )rS   z6Defines an optional child element for MetaOxmlElement.rJ   r    rc   rd   c                   sF   t t| || |   |   |   |   |   |   dS rg   )	r^   rS   rV   r   r   r   r   _add_get_or_adder_add_removerrk   ra   r   r   rV     s    z ZeroOrOne.populate_class_membersc                   s0   dd fdd}d j  |_  j| dS )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   ri   r   )r   r   r   rs   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.N)r   rE   r   _get_or_add_method_name)r%   r   r   rs   r   r   )  s
    zZeroOrOne._add_get_or_adderc                   s0   dd fdd}d j  |_  j| dS )zIAdd a ``_remove_x()`` method to the element class for this child element.r|   r   c                   s   |   j d S r)   )
remove_allr   r   rs   r   r   _remove_child<  s    z-ZeroOrOne._add_remover.<locals>._remove_childz#Remove all ``<%s>`` child elements.N)r   rE   r   r   )r%   r   r   rs   r   r   9  s    zZeroOrOne._add_removerc                 C  s
   d| j  S )Nzget_or_add_%sr   rs   r   r   r   r   B  s    z!ZeroOrOne._get_or_add_method_name)
rB   rC   rD   rE   rV   r   r   r   r   rw   r   r   ra   r   rS     s   
	rS   c                      sp   e Zd ZdZddddddZdd	d
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 )rT   zeCorrespondes to an ``EG_*`` element group where at most one of its members may
    appear as a child.r   zSequence[Choice]r   )choicesr   c                 C  s   || _ || _d S r)   )_choicesr   )r%   r   r   r   r   r   rY   K  s    zZeroOrOneChoice.__init__rJ   r    rc   rd   c                   sD   t t| || |   | jD ]}||| j| j q |   dS rg   )r^   rT   rV   _add_choice_getterr   ri   r   _add_group_remover)r%   re   rf   choicera   r   r   rV   O  s
    
z&ZeroOrOneChoice.populate_class_membersc                 C  s"   t | jdd}t| j| j| dS )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)rl   _choice_getterro   rh   ri   rp   r   r   r   r   W  s    z"ZeroOrOneChoice._add_choice_getterc                   s*   d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   tagnamers   r   r   _remove_choice_groupb  s    
z@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groupz9Remove the current choice group child element if present.N)rE   r    _remove_choice_group_method_name)r%   r   r   rs   r   r   ^  s    z"ZeroOrOneChoice._add_group_removerc                   s   dd fdd}d|_ |S )r   r|   r   c                   s   | j  j S r)   )first_child_found_inr   r   rs   r   r   get_group_member_elementn  s    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.)rE   )r%   r   r   rs   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   )r7   r   r   r   r   r;   {  r<   z7ZeroOrOneChoice._member_nsptagnames.<locals>.<listcomp>)r   rs   r   r   r   r   w  s    z#ZeroOrOneChoice._member_nsptagnamesc                 C  s
   d| j  S r   r   rs   r   r   r   r   }  s    z0ZeroOrOneChoice._remove_choice_group_method_name)r   )rB   rC   rD   rE   rY   rV   r   r   rl   r   r   r   r   rw   r   r   ra   r   rT   G  s   

rT   c                      s   e Zd ZdZdd ZdddddZd	dd
ddZdddddZeddddZ	ddd fddZ
ed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>)rb   rB   _nsptagidrs   r   r   r   __repr__  s
    zBaseOxmlElement.__repr__r    z_Element | None)tagnamesr   c                 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_inr
   )elmr   c                 G  s,   | j | }|d ur|| n
| | |S r)   )r   Zaddpreviousappend)r%   r   r   	successorr   r   r   r     s
    

z%BaseOxmlElement.insert_element_beforerc   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_allrv   c                 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   rs   r   r   r   r     s    zBaseOxmlElement.xmlr   )	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)r^   xpathr   )r%   r   ra   r   r   r     s    zBaseOxmlElement.xpathc                 C  s   t | jS r)   )r   Zfrom_clark_namer   rs   r   r   r   r     s    zBaseOxmlElement._nsptag)rB   rC   rD   rE   r   r   r   r   rl   r   r   r   rw   r   r   ra   r   r|     s   r|   )	metaclass)-rE   
__future__r   rF   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   rI   typerJ   rZ   rP   rQ   r   r   rN   rO   rR   rS   rT   r|   r   r   r   r   <module>   s6    	;+?/ ":+<