o
    	'f
e                     @  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
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rTd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DictListSequenceTuple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)encodingpretty_print)r   tostring	XmlString)r   xml r   J/home/ubuntu/flask/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    lineslines_otherline
line_otherr   r   r   __eq__5   s   
zXmlString.__eq__c                 C  s   |  | S N)r/   )r*   r    r   r   r   __ne__A      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*   r3   attr_lstr   r   r   	_attr_seqD   s   zXmlString._attr_seqr-   line_2c                 C  sd   |  |\}}}}|  |\}}}	}
||krdS | || |kr$dS ||	kr*dS ||
kr0dS dS )zZReturn True if the element in `line_2` is XML equivalent to the element in
        `line`.FT)_parse_liner9   )r*   r-   r:   frontr3   closetextfront_2attrs_2close_2text_2r   r   r   r)   M   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) rD   rD   rD   c                   s   g | ]}  |qS r   )group).0nmatchr   r   
<listcomp>b   s    z)XmlString._parse_line.<locals>.<listcomp>      )_xml_elm_line_pattrI   range)clsr-   r<   r3   r=   r>   r   rH   r   r;   \   s
    zXmlString._parse_lineN)r    r!   r"   r#   )r3   r%   r"   r4   )r-   r%   r:   r%   )r-   r%   r"   rC   )__name__
__module____qualname____doc__recompilerM   r/   r1   r9   r)   classmethodr;   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 r0   )
OneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoiceitemsr$   populate_class_members)rO   rY   rZ   r\   dispatchablekeyvaluer   r   r   __init__l   s   	
zMetaOxmlElement.__init__N)rY   r%   rZ   r[   r\   r]   )rP   rQ   rR   rS   rj   r   r   r   r   rX   i   s    rX   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 r0   )superrk   rj   
_attr_name_simple_type)r*   rl   rm   	__class__r   r   rj      s   
zBaseAttribute.__init__element_clsrX   	prop_namer"   Nonec                 C  s   || _ || _|   dS z-Add the appropriate methods to `element_cls`.N)_element_cls
_prop_name_add_attr_propertyr*   ru   rv   r   r   r   rf      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setattrry   rz   r*   	property_r   r   r   r{      s   z BaseAttribute._add_attr_propertyc                 C  s   d| j v r
t| j S | j S )N:)rq   r   r*   r   r   r   _clark_name   s   

zBaseAttribute._clark_name'Callable[[BaseOxmlElement], Any | None]c                 C     d S r0   r   r   r   r   r   r~      s   zBaseAttribute._getter-Callable[[BaseOxmlElement, Any | None], None]c                 C  r   r0   r   r   r   r   r   r      s   zBaseAttribute._setter)rl   r%   rm   rn   ru   rX   rv   r%   r"   rw   r"   r   )r"   r   )rP   rQ   rR   rS   rj   rf   r{   r}   r   r~   r   __classcell__r   r   rs   r   rk   {   s    
	

rk   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 )r`   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.
    Nrl   r%   rm   rn   default#BaseXmlEnum | BaseSimpleType | Nonec                   s   t t| || || _d S r0   )rp   r`   rj   _default)r*   rl   rm   r   rs   r   r   rj      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.rr   rP   rq   r   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 r0   )getr   r   rr   from_xmlr   attr_str_valuer   r   r   get_attr_value   s   z1OptionalAttribute._getter.<locals>.get_attr_valueNr   r   r"   r   r   rS   r*   r   r   r   r   r~      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   ri   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 r0   )r   r   attribrr   to_xmlsetr   ri   	str_valuer   r   r   set_attr_value   s   

z1OptionalAttribute._setter.<locals>.set_attr_valueN)r   r   ri   r   r   r*   r   r   r   r   r      s   zOptionalAttribute._setterr0   )rl   r%   rm   rn   r   r   r   r"   r   )
rP   rQ   rR   rS   rj   r}   r   r~   r   r   r   r   rs   r   r`      s    	
	r`   c                   @  s8   e Zd ZdZedd ZedddZedd	d
ZdS )ra   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   r   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   r   r   rq   tagrr   r   r   r   r   r   r     s   
z1RequiredAttribute._getter.<locals>.get_attr_valueNr   r   r   r   r   r   r~      s   	zRequiredAttribute._getterr   c                   r   )	zIfunction object suitable for "set" side of attribute property descriptor.r   r   ri   r   c                   s6    j |}|d u rtd| d|  j| d S )Nzcannot assign z to this required attribute)rr   r   
ValueErrorr   r   r   r   r   r   r     s   z1RequiredAttribute._setter.<locals>.set_attr_valueN)r   r   ri   r   r   r   r   r   r   r     s   zRequiredAttribute._setterN)r"   r   r   )rP   rQ   rR   rS   r}   r   r~   r   r   r   r   r   ra      s    	
ra   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                   ro   r0   )rp   r   rj   _nsptagname_successors)r*   r   r   rs   r   r   rj   "  s   
z_BaseChildElement.__init__ru   rX   rv   r"   rw   c                 C  s   || _ || _dS )zFBaseline behavior for adding the appropriate methods to `element_cls`.N)ry   rz   r|   r   r   r   rf   '  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   r3   r   c                   sH   t |  j}| }| D ]
\}}t||| qt |  j}|| |S r0   )getattr_new_method_namere   r   _insert_method_name)r   r3   
new_methodchildrh   ri   insert_methodr   r   r   
_add_child1  s   z0_BaseChildElement._add_adder.<locals>._add_childSAdd a new ``<%s>`` child element unconditionally, inserted in the correct sequence.N)r   r   r3   r   )r   rS   _add_to_class_add_method_name)r*   r   r   r   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   rS   r   r   )r*   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)r}   r~   r   ry   rz   r   r   r   r   _add_getterJ     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 r0   )insert_element_beforer   r   r   r   r   r   _insert_childT  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   rS   r   r   )r*   r   r   r   r   _add_inserterQ  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)rz   r}   _list_getterr   ry   )r*   rv   r   r   r   r   _add_list_getter^  s   
z"_BaseChildElement._add_list_getterc                 C  
   d| j  S )Nz_add_%srz   r   r   r   r   r   e     
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 r0   )r   r   )r   private_add_methodr   r   r   r   	add_childl  s   z6_BaseChildElement._add_public_adder.<locals>.add_childr   Nr   r   )r   rS   r   _public_add_method_name)r*   r   r   r   r   _add_public_adderi  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)hasattrry   r   )r*   r   r   r   r   r   r   w  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 r0   r   r   r   r*   r   r   new_child_element  s   
z5_BaseChildElement._creator.<locals>.new_child_elementNr   )docx.oxml.parserr   )r*   r   r   r   r   r   ~  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 r0   )findr   r   r   r   r   r   get_child_element     z4_BaseChildElement._getter.<locals>.get_child_elementz0``<%s>`` child element or |None| if not present.Nr   r   rS   r*   r   r   r   r   r~     s   	z_BaseChildElement._getterc                 C  r   )Nz
_insert_%sr   r   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   r0   )findallr   r   r   r   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   r   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   r   r   r   r   r     s   
z)_BaseChildElement._public_add_method_namec                 C  r   Nz
_remove_%sr   r   r   r   r   _remove_method_name  r   z%_BaseChildElement._remove_method_namec                 C  r   )Nz_new_%sr   r   r   r   r   r     r   z"_BaseChildElement._new_method_namer   )r   r%   r   r   r   )r   r%   r   r   )r"   r   )rP   rQ   rR   rS   rj   rf   r   r   r   r   r   r   r   r   r   r}   r   r~   r   r   r   r   r   r   r   r   rs   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 )ChoicezZDefines a child element belonging to a group, only one of which may appear as a
    child.c                 C  s   | j S r0   r   r   r   r   r   r     s   zChoice.nsptagnameru   rX   group_prop_namer%   r   r   r"   rw   c                 C  s>   || _ || _|| _|   |   |   |   |   dS rx   )ry   _group_prop_namer   r   r   r   r   _add_get_or_change_to_method)r*   ru   r   r   r   r   r   rf     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 r0   )r   rz   _remove_group_method_namer   )r   r   remove_group_method
add_methodr   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   rS   r   _get_or_change_to_method_name)r*   r   r   r   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.r   rK   r   N)r   index)r*   startr   r   r   rz     s   zChoice._prop_namec                 C  r   )Nzget_or_change_to_%sr   r   r   r   r   r     r   z$Choice._get_or_change_to_method_namec                 C  r   r   )r   r   r   r   r   r     r   z Choice._remove_group_method_nameN)ru   rX   r   r%   r   r   r"   rw   )rP   rQ   rR   rS   r}   r   rf   r   rz   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 )r^   z5Defines a required child element for MetaOxmlElement.r   r%   c                   s   t t| |d d S )Nr   )rp   r^   rj   )r*   r   rs   r   r   rj     s   zOneAndOnlyOne.__init__ru   rX   rv   r"   rw   c                   s   t t| || |   dS rx   )rp   r^   rf   r   r|   rs   r   r   rf     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   r   r   r   r     s   z0OneAndOnlyOne._getter.<locals>.get_child_elementz Required ``<%s>`` child element.Nr   r   r   r   r   r   r~     s   	zOneAndOnlyOne._getter)r   r%   r   )	rP   rQ   rR   rS   rj   rf   r}   r~   r   r   r   rs   r   r^     s    r^   c                      "   e Zd ZdZd
 fdd	Z  ZS )r_   zYDefines a repeating child element for MetaOxmlElement that must appear at least
    once.ru   rX   rv   r%   r"   rw   c                   H   t t| || |   |   |   |   |   t|| dS rx   )	rp   r_   rf   r   r   r   r   r   delattrr|   rs   r   r   rf        z OneOrMore.populate_class_membersr   rP   rQ   rR   rS   rf   r   r   r   rs   r   r_     s    r_   c                      r   )rb   z@Defines an optional repeating child element for MetaOxmlElement.ru   rX   rv   r%   r"   rw   c                   r   rx   )	rp   rb   rf   r   r   r   r   r   r   r|   rs   r   r   rf   -  r   z!ZeroOrMore.populate_class_membersr   r   r   r   rs   r   rb   *  s    rb   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 )rc   z6Defines an optional child element for MetaOxmlElement.ru   rX   rv   r%   r"   rw   c                   sF   t t| || |   |   |   |   |   |   dS rx   )	rp   rc   rf   r   r   r   r   _add_get_or_adder_add_removerr|   rs   r   r   rf   =  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 r0   )r   rz   r   )r   r   r   r   r   r   get_or_add_childM  s
   z5ZeroOrOne._add_get_or_adder.<locals>.get_or_add_childz>Return the ``<%s>`` child element, newly added if not present.Nr   )r   rS   r   _get_or_add_method_name)r*   r   r   r   r   r   I  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 r0   )
remove_allr   r   r   r   r   _remove_child\  r   z-ZeroOrOne._add_remover.<locals>._remove_childz#Remove all ``<%s>`` child elements.Nr   )r   rS   r   r   )r*   r   r   r   r   r   Y  s
   zZeroOrOne._add_removerc                 C  r   )Nzget_or_add_%sr   r   r   r   r   r   d  r   z!ZeroOrOne._get_or_add_method_namer   )
rP   rQ   rR   rS   rf   r   r   r   r   r   r   r   rs   r   rc   :  s    rc   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 )rd   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 r0   )_choicesr   )r*   r   r   r   r   r   rj   m  s   
zZeroOrOneChoice.__init__ru   rX   rv   r%   r"   rw   c                   sD   t t| || |   | jD ]}||| j| j q|   dS rx   )rp   rd   rf   _add_choice_getterr   rz   r   _add_group_remover)r*   ru   rv   choicers   r   r   rf   q  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)r}   _choice_getterr   ry   rz   r   r   r   r   r  }  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 r0   )_member_nsptagnamesr   )r   tagnamer   r   r   _remove_choice_group  s   
z@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groupz9Remove the current choice group child element if present.Nr   )rS   r    _remove_choice_group_method_name)r*   r  r   r   r   r    s   z"ZeroOrOneChoice._add_group_removerc                   s   d fdd}d|_ |S )r   r   r   c                   s   | j  j S r0   )first_child_found_inr  r   r   r   r   get_group_member_element  r2   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   )rS   )r*   r
  r   r   r   r    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   )rF   r  r   r   r   rJ     s    z7ZeroOrOneChoice._member_nsptagnames.<locals>.<listcomp>)r   r   r   r   r   r    s   z#ZeroOrOneChoice._member_nsptagnamesc                 C  r   r   r   r   r   r   r   r    r   z0ZeroOrOneChoice._remove_choice_group_method_namer   )r   r   r   r   r   )rP   rQ   rR   rS   rj   rf   r  r  r}   r  r   r  r  r   r   r   rs   r   rd   i  s    

rd   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>)rt   rP   _nsptagidr   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 r0   )r	  addpreviousappend)r*   r  r  	successorr   r   r   r     s   


z%BaseOxmlElement.insert_element_beforerw   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  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   r   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)rp   xpathr   )r*   r  rs   r   r   r    s   zBaseOxmlElement.xpathc                 C  s   t | jS r0   )r   from_clark_namer   r   r   r   r   r    s   zBaseOxmlElement._nsptag)r  r%   r"   r  )r  r   r  r%   )r  r%   r"   rw   )r"   r%   )r  r%   r"   r   )rP   rQ   rR   rS   r  r	  r   r   r}   r   r  r  r   r   r   rs   r   r     s    


	r   )	metaclass)r   r   )0rS   
__future__r   rT   typingr   r   r   r   r   r   r	   r
   r   lxmlr   
lxml.etreer   r   docx.oxml.exceptionsr   docx.oxml.nsr   r   r   docx.sharedr   docx.enum.baser   docx.oxml.simpletypesr   r   r%   r   rW   typerX   rk   r`   ra   r   r   r^   r_   rb   rc   rd   r   r   r   r   r   <module>   s<   ,
	=1?0 $; /
B
