
    ,hc                       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rdd
lmZ ddlmZ d)dZ G d de       Z! ed      Z" G d de#      Z$ G d d      Z% G d de%      Z& G d de%      Z' G d d      Z( G d de(      Z) G d de(      Z* G d de(      Z+ G d  d!e(      Z, G d" d#e(      Z- G d$ d%e(      Z. G d& d'ej"                  e$(      Z/y)*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)BaseSimpleTypec                H    t        j                  | dd      }t        |      S )z[Serialize `element` to human-readable XML suitable for tests.

    No XML declaration.
    unicodeT)encodingpretty_print)r   tostring	XmlString)elementxmls     T/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/oxml/xmlchemy.pyserialize_for_readingr        s     
 ..94
HCS>    c                  f    e Zd ZdZ ej
                  d      Zd	dZd	dZd
dZ	ddZ
edd       Zy)r   z]Provides string comparison override suitable for serialized XML that is useful
    for tests.z)( *</?[\w:]+)(.*?)(/?>)([^<]*</[\w:]+>)?$c                    t        |t              sy| j                         }|j                         }t        |      t        |      k7  ryt	        ||      D ]  \  }}| j                  ||      r y y)NFT)
isinstancestr
splitlineslenzip_eq_elm_strs)selfotherlineslines_otherline
line_others         r   __eq__zXmlString.__eq__5   sp    %%!&&(u:[)) #E; 7 	D*$$T:6	 r!   c                &    | j                  |       S N)r0   )r*   r+   s     r   __ne__zXmlString.__ne__A   s    ;;u%%%r!   c                X    |j                         }|j                         }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*   attrsattr_lsts      r   	_attr_seqzXmlString._attr_seqD   s%    
 ;;=hr!   c                    | j                  |      \  }}}}| j                  |      \  }}}	}
||k7  ry| j                  |      | j                  |      k7  ry||	k7  ry||
k7  ryy)zZReturn True if the element in `line_2` is XML equivalent to the element in
        `line`.FT)_parse_liner:   )r*   r.   line_2frontr8   closetextfront_2attrs_2close_2text_2s              r   r)   zXmlString._eq_elm_strsM   sv     %)$4$4T$:!ueT,0,<,<V,D)'6G>>% DNN7$;;G6>r!   c                    | j                   j                  |      }|yt        dd      D cg c]  }|j                  |       c}\  }}}}||||fS c c}w )zI(front, attrs, close, text) 4-tuple result of parsing XML element `line`.) rF   rF   rF         )_xml_elm_line_pattmatchrangegroup)clsr.   rJ   nr>   r8   r?   r@   s           r   r<   zXmlString._parse_line\   s^     &&,,T2=!=B1a[$IU[[^$I!ueTeUD(( %Js   AN)r+   objectreturnbool)r8   r%   rP   z	List[str])r.   r%   r=   r%   )r.   r%   rP   zTuple[str, str, str, str])__name__
__module____qualname____doc__recompilerI   r0   r3   r:   r)   classmethodr<    r!   r   r   r   )   sC     $$PQ
&  ) )r!   r   _Tc                      e Zd ZdZddZy)MetaOxmlElementzMetaclass for BaseOxmlElement.c                    t         t        t        t        t        t
        t        f}|j                         D ]$  \  }}t        ||      s|j                  | |       & y r2   )
OneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoiceitemsr$   populate_class_members)rM   clsnamebases	namespacedispatchablekeyvalues          r   __init__zMetaOxmlElement.__init__l   sT    
 $//+ 	7JC%.,,S#6	7r!   N)rg   r%   rh   zTuple[type, ...]ri   zDict[str, Any])rR   rS   rT   rU   rm   rY   r!   r   r\   r\   i   s
    (7r!   r\   c                  j     e Zd ZdZd fdZd	dZd Zed        Zed
d       Z	e	 	 dd       Z
 xZS )BaseAttributezZBase class for OptionalAttribute and RequiredAttribute.

    Provides common methods.
    c                F    t         t        |           || _        || _        y r2   )superro   rm   
_attr_name_simple_type)r*   	attr_namesimple_type	__class__s      r   rm   zBaseAttribute.__init__   s    mT+-#'r!   c                @    || _         || _        | j                          yz-Add the appropriate methods to `element_cls`.N)_element_cls
_prop_name_add_attr_propertyr*   element_cls	prop_names      r   rf   z$BaseAttribute.populate_class_members   s    '#!r!   c                    t        | j                  | j                  d      }t        | j                  | j
                  |       y)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_s     r   r{   z BaseAttribute._add_attr_property   s0     T\\4<<>	!!4??I>r!   c                `    d| j                   v rt        | j                         S | j                   S )N:)rr   r   r*   s    r   _clark_namezBaseAttribute._clark_name   s'    $//!doo&&r!   c                     y r2   rY   r   s    r   r   zBaseAttribute._getter   s    BEr!   c                     y r2   rY   r   s    r   r   zBaseAttribute._setter   s     9<r!   )rt   r%   ru   (Type[BaseXmlEnum] | Type[BaseSimpleType]r}   r\   r~   r%   rP   NonerP   z'Callable[[BaseOxmlElement], Any | None])rP   z-Callable[[BaseOxmlElement, Any | None], None])rR   rS   rT   rU   rm   rf   r{   r   r   r   r   __classcell__rv   s   @r   ro   ro   {   sU    
(
"?  
 E E<	6< <r!   ro   c                  j     e Zd ZdZ	 d	 	 	 	 	 d fdZed        Ze	 	 dd       Zed	d       Z x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.
    c                <    t         t        |   ||       || _        y r2   )rq   r`   rm   _default)r*   rt   ru   defaultrv   s       r   rm   zOptionalAttribute.__init__   s     	/	;Gr!   c                N    | j                   j                   d| j                   dS )z;String to use as `__doc__` attribute of attribute property. 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.rs   rR   rr   r   s    r   
_docstringzOptionalAttribute._docstring   s4       ))* +//" #9:	
r!   c                >     	 	 	 	 d fd} j                   |_        |S )zJFunction suitable for `__get__()` method on attribute property descriptor.c                    | j                  j                        }|j                  S j                  j	                  |      S r2   )getr   r   rs   from_xmlobjattr_str_valuer*   s     r   get_attr_valuez1OptionalAttribute._getter.<locals>.get_attr_value   s@     !WWT%5%56N%}}$$$--n==r!   r   BaseOxmlElementrP   
Any | Noner   rU   r*   r   s   ` r   r   zOptionalAttribute._getter   s,    	> 	>	> "&r!   c                     d fd}|S )zJFunction suitable for `__set__()` method on attribute property descriptor.c                Z   ||j                   k(  r0j                  | j                  v r| j                  j                  = y j                  j	                  |      }|0j                  | j                  v r| j                  j                  = y | j                  j                  |       y r2   )r   r   attribrs   to_xmlsetr   rl   	str_valuer*   s      r   set_attr_valuez1OptionalAttribute._setter.<locals>.set_attr_value   s    } 6##szz1

4#3#34))007I ##szz1

4#3#34GGD$$i0r!   )r   r   rl   r   rY   r*   r   s   ` r   r   zOptionalAttribute._setter   s    
	1 r!   r2   )rt   r%   ru   r   r   z0BaseXmlEnum | BaseSimpleType | str | bool | Noner   rP   z&Callable[[BaseOxmlElement, Any], None])
rR   rS   rT   rU   rm   r   r   r   r   r   r   s   @r   r`   r`      su     EI	   >  B	  
 
 	0    r!   r`   c                  D    e Zd ZdZed        Zedd       Zedd       Zy)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                N    | j                   j                  d| j                  dS )zaReturn the string to use as the ``__doc__`` attribute of the property for
        this attribute.r   z`` attribute.r   r   s    r   r   zRequiredAttribute._docstring   s$    
 &&OO
 	
r!   c                6     d fd} j                   |_        |S )zDfunction object suitable for "get" side of attr property descriptor.c                    | j                  j                        }|%t        dj                  d| j                        j
                  j                  |      S )Nz
required 'z#' attribute not present on element )r   r   r   rr   tagrs   r   r   s     r   r   z1RequiredAttribute._getter.<locals>.get_attr_value   sV     WWT%5%56N%%KO??\_\c\cd  $$--n==r!   r   r   r   s   ` r   r   zRequiredAttribute._getter   s    	> "&r!   c                     d fd}|S )zIfunction object suitable for "set" side of attribute property descriptor.c                    j                   j                  |      }|t        d| d      | j                  j                  |       y )Nzcannot assign z to this required attribute)rs   r   
ValueErrorr   r   r   s      r   r   z1RequiredAttribute._setter.<locals>.set_attr_value  sH    ))007I  >%8S!TUUGGD$$i0r!   )r   r   rl   r   rY   r   s   ` r   r   zRequiredAttribute._setter  s    	1 r!   N)rP   z Callable[[BaseOxmlElement], Any]r   )rR   rS   rT   rU   r   r   r   r   rY   r!   r   ra   ra      sC     
 
   	 	r!   ra   c                       e Zd ZdZdd fdZddZd Zd Zd Zd Z	d Z
ed	        Zd
 ZddZedd       Zed        Zed        Zed        Zed        Zed        Zed        Z xZS )_BaseChildElementzBase class for the child-element classes.

    The child-element sub-classes correspond to varying cardinalities, such as ZeroOrOne
    and ZeroOrMore.
    c                F    t         t        |           || _        || _        y r2   )rq   r   rm   _nsptagname_successors)r*   
nsptagname
successorsrv   s      r   rm   z_BaseChildElement.__init__  s!    /1%%r!   c                     || _         || _        y)zFBaseline behavior for adding the appropriate methods to `element_cls`.N)ry   rz   r|   s      r   rf   z(_BaseChildElement.populate_class_members   s    '#r!   c                r     d fd}d j                   z  |_         j                   j                  |       y)zGAdd an ``_add_x()`` method to the element class for this child element.c                    t        | j                        } |       }|j                         D ]  \  }}t        |||        t        | j                        } ||       |S r2   )getattr_new_method_namere   r   _insert_method_name)r   r8   
new_methodchildrk   rl   insert_methodr*   s          r   
_add_childz0_BaseChildElement._add_adder.<locals>._add_child(  s`     d&;&;<JLE#kkm +
UsE*+#C)A)ABM% Lr!   SAdd a new ``<%s>`` child element unconditionally, inserted in the correct sequence.N)r   r   r8   r   )r   rU   _add_to_class_add_method_name)r*   r   s   ` r   
_add_adderz_BaseChildElement._add_adder%  s;    	#%)%5%56 	 	400*=r!   c                |    | j                   }d| j                  z  |_        | j                  | j                  |       y)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   rU   r   r   )r*   creators     r   _add_creatorz_BaseChildElement._add_creator7  s?     --(*.*:*:; 	 	400':r!   c                t    t        | j                  dd      }t        | j                  | j                  |       y)z]Add a read-only ``{prop_name}`` property to the element class for this child
        element.N)r   r   r   ry   rz   r   s     r   _add_getterz_BaseChildElement._add_getterA  s,     T\\46	!!4??I>r!   c                r     d fd}d j                   z  |_         j                   j                  |       y)zJAdd an ``_insert_x()`` method to the element class for this child element.c                B     | j                   |gj                    |S r2   )insert_element_beforer   r   r   r*   s     r   _insert_childz6_BaseChildElement._add_inserter.<locals>._insert_childK  s#    %C%%e?d.>.>?Lr!   zYReturn the passed ``<%s>`` element after inserting it as a child in the correct sequence.N)r   r   r   r   )r   rU   r   r   )r*   r   s   ` r   _add_inserterz_BaseChildElement._add_inserterH  s;    	
)+/+;+;< 	 	433]Cr!   c                ~    d| j                   z  }t        | j                  dd      }t        | j                  ||       y)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*   r~   r   s      r   _add_list_getterz"_BaseChildElement._add_list_getterU  s8     t.	T..d;	!!9i8r!   c                     d| j                   z  S )Nz_add_%srz   r   s    r   r   z"_BaseChildElement._add_method_name\      4??**r!   c                r     d fd}d j                   z  |_         j                   j                  |       y)z<Add a public ``add_x()`` method to the parent element class.c                B    t        | j                        } |       }|S r2   )r   r   )r   private_add_methodr   r*   s      r   	add_childz6_BaseChildElement._add_public_adder.<locals>.add_childc  s#    !(d.C.C!D&(ELr!   r   Nr   r   )r   rU   r   _public_add_method_name)r*   r   s   ` r   _add_public_adderz#_BaseChildElement._add_public_adder`  s;    	#%)%5%56 	 	477Cr!   c                `    t        | j                  |      ryt        | j                  ||       y)zbAdd `method` to the target class as `name`, unless `name` is already defined
        on the class.N)hasattrry   r   )r*   namemethods      r   r   z_BaseChildElement._add_to_classn  s)     4$$d+!!40r!   c                $     ddl m d fd}|S )zHCallable that creates an empty element of the right type, with no attrs.r   )OxmlElementc                (     j                         S r2   r   )r   r   r*   s    r   new_child_elementz5_BaseChildElement._creator.<locals>.new_child_elementz  s    t//00r!   r   )docx.oxml.parserr   )r*   r   r   s   ` @r   r   z_BaseChildElement._creatoru  s     	1	1 ! r!   c                <     d fd}d j                   z  |_        |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.
        c                L    | j                  t        j                              S r2   )findr   r   r   r*   s    r   get_child_elementz4_BaseChildElement._getter.<locals>.get_child_element  s    88Bt//011r!   z0``<%s>`` child element or |None| if not present.r   r   rU   r*   r   s   ` r   r   z_BaseChildElement._getter  s(    	2 ?AQAQQ 	! ! r!   c                     d| j                   z  S )Nz
_insert_%sr   r   s    r   r   z%_BaseChildElement._insert_method_name      doo--r!   c                <     d fd}d j                   z  |_        |S )z[Return a function object suitable for the "get" side of a list property
        descriptor.c                L    | j                  t        j                              S r2   )findallr   r   r   s    r   get_child_element_listz>_BaseChildElement._list_getter.<locals>.get_child_element_list  s    ;;r$"2"2344r!   zPA list containing each of the ``<%s>`` child elements, in the order they appear.r   r   )r*   r   s   ` r   r   z_BaseChildElement._list_getter  s+    
	5 "&"2"23 	& &%r!   c                     d| j                   z  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   r   s    r   r   z)_BaseChildElement._public_add_method_name  s     $//))r!   c                     d| j                   z  S Nz
_remove_%sr   r   s    r   _remove_method_namez%_BaseChildElement._remove_method_name  r   r!   c                     d| j                   z  S )Nz_new_%sr   r   s    r   r   z"_BaseChildElement._new_method_name  r   r!   rY   )r   r%   r   Tuple[str, ...]r   )r   r%   r   zCallable[..., Any])rP   z,Callable[[BaseOxmlElement], BaseOxmlElement])rR   rS   rT   rU   rm   rf   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   s   @r   r   r     s    &
$
>$;?D9 + +D1 ! ! ! !  . . & & * * . . + +r!   r   c                  n    e Zd ZdZed        Z	 	 	 	 	 	 	 	 d	dZd Zed        Ze	d        Z
e	d        Zy)
ChoicezZDefines a child element belonging to a group, only one of which may appear as a
    child.c                    | j                   S r2   r   r   s    r   r   zChoice.nsptagname  s    r!   c                    || _         || _        || _        | j                          | j	                          | j                          | j                          | j                          yrx   )ry   _group_prop_namer   r   r   r   r   _add_get_or_change_to_method)r*   r}   group_prop_namer   s       r   rf   zChoice.populate_class_members  sV     ( /%))+r!   c                r     d fd}d j                   z  |_         j                   j                  |       y)zZAdd a ``get_or_change_to_x()`` method to the element class for this child
        element.c                    t        | j                        }||S t        | j                        } |        t        | j                        } |       }|S r2   )r   rz   _remove_group_method_namer   )r   r   remove_group_method
add_methodr*   s       r   get_or_change_to_childzCChoice._add_get_or_change_to_method.<locals>.get_or_change_to_child  sU    C1E ")#t/M/M"N! d&;&;<JLELr!   zFReturn the ``<%s>`` child, replacing any other group element if found.Nr   )r   rU   r   _get_or_change_to_method_name)r*   r  s   ` r   r
  z#Choice._add_get_or_change_to_method  s;    	 X*& 	4==?UVr!   c                |    d| j                   v r| j                   j                  d      dz   nd}| j                   |d S )zDProperty name computed from tag name, e.g. a:schemeClr -> schemeClr.r   rG   r   N)r   index)r*   starts     r   rz   zChoice._prop_name  sB     47$:J:J3J  &&s+a/PQ''r!   c                     d| j                   z  S )Nzget_or_change_to_%sr   r   s    r   r  z$Choice._get_or_change_to_method_name  s    $t66r!   c                     d| j                   z  S r   )r	  r   s    r   r  z Choice._remove_group_method_name  s    d3333r!   N)r}   r\   r  r%   r   r  rP   r   )rR   rS   rT   rU   r   r   rf   r
  rz   r   r  r  rY   r!   r   r  r    s        ,$, , $	,
 
,"W& ( (
 7 7 4 4r!   r  c                  @     e Zd ZdZd fdZd fdZed        Z xZS )r^   z5Defines a required child element for MetaOxmlElement.c                .    t         t        |   |d       y )NrY   )rq   r^   rm   )r*   r   rv   s     r   rm   zOneAndOnlyOne.__init__  s    mT+J;r!   c                N    t         t        |   ||       | j                          yrx   )rq   r^   rf   r   r*   r}   r~   rv   s      r   rf   z$OneAndOnlyOne.populate_class_members  s     mT9+yQr!   c                <     d fd}d j                   z  |_        |S )XReturn a function object suitable for the "get" side of the property
        descriptor.c                    | j                  t        j                              }|t        dj                  z        |S )Nz+required ``<%s>`` child element not present)r   r   r   r   r   s     r   r   z0OneAndOnlyOne._getter.<locals>.get_child_element   sC    HHR 0 012E}%ADDTDTT  Lr!   z Required ``<%s>`` child element.r   r   r   s   ` r   r   zOneAndOnlyOne._getter  s%    
	 %GIYIY$Y!  r!   )r   r%   r   )	rR   rS   rT   rU   rm   rf   r   r   r   r   s   @r   r^   r^     s$    ?<
 ! !r!   r^   c                  $     e Zd ZdZd fdZ xZS )r_   zYDefines a repeating child element for MetaOxmlElement that must appear at least
    once.c                    t         t        |   ||       | j                          | j	                          | j                          | j                          | j                          t        ||       yrx   )	rq   r_   rf   r   r   r   r   r   delattrr  s      r   rf   z OneOrMore.populate_class_members  sX    i5k9M Y'r!   r   rR   rS   rT   rU   rf   r   r   s   @r   r_   r_     s    ( (r!   r_   c                  $     e Zd ZdZd fdZ xZS )rb   z@Defines an optional repeating child element for MetaOxmlElement.c                    t         t        |   ||       | j                          | j	                          | j                          | j                          | j                          t        ||       yrx   )	rq   rb   rf   r   r   r   r   r   r!  r  s      r   rf   z!ZeroOrMore.populate_class_members  sX    j$6{IN Y'r!   r   r"  r   s   @r   rb   rb     s    J( (r!   rb   c                  @     e Zd ZdZd fdZd Zd Zed        Z xZ	S )rc   z6Defines an optional child element for MetaOxmlElement.c                    t         t        |   ||       | j                          | j	                          | j                          | j                          | j                          | j                          yrx   )	rq   rc   rf   r   r   r   r   _add_get_or_adder_add_removerr  s      r   rf   z ZeroOrOne.populate_class_members,  sZ    i5k9M r!   c                r     d fd}d j                   z  |_         j                   j                  |       y)zTAdd a ``get_or_add_x()`` method to the element class for this child
        element.c                r    t        | j                        }|t        | j                        } |       }|S r2   )r   rz   r   )r   r   r  r*   s      r   get_or_add_childz5ZeroOrOne._add_get_or_adder.<locals>.get_or_add_child:  s6    C1E}$S$*?*?@
"Lr!   z>Return the ``<%s>`` child element, newly added if not present.Nr   )r   rU   r   _get_or_add_method_name)r*   r+  s   ` r   r'  zZeroOrOne._add_get_or_adder6  s;    	 M$  	4779IJr!   c                r     d fd}d j                   z  |_         j                   j                  |       y)zIAdd a ``_remove_x()`` method to the element class for this child element.c                <    | j                  j                         y r2   )
remove_allr   r   s    r   _remove_childz-ZeroOrOne._add_remover.<locals>._remove_childI  s    NN4++,r!   z#Remove all ``<%s>`` child elements.Nr   )r   rU   r   r  )r*   r0  s   ` r   r(  zZeroOrOne._add_removerF  s4    	- "G$JZJZ Z433]Cr!   c                     d| j                   z  S )Nzget_or_add_%sr   r   s    r   r,  z!ZeroOrOne._get_or_add_method_nameO  s    00r!   r   )
rR   rS   rT   rU   rf   r'  r(  r   r,  r   r   s   @r   rc   rc   )  s+    @K D 1 1r!   rc   c                  j     e Zd ZdZd	d
dZd fdZd Zd Zed        Z	e
d        Ze
d        Z xZS )rd   zeCorrespondes to an ``EG_*`` element group where at most one of its members may
    appear as a child.c                     || _         || _        y r2   )_choicesr   )r*   choicesr   s      r   rm   zZeroOrOneChoice.__init__X  s    %r!   c                    t         t        |   ||       | j                          | j                  D ])  }|j                  || j
                  | j                         + | j                          yrx   )rq   rd   rf   _add_choice_getterr4  rz   r   _add_group_remover)r*   r}   r~   choicerv   s       r   rf   z&ZeroOrOneChoice.populate_class_members\  s]    ot;KS!mm 	ZF))+tHXHXY	Z!r!   c                t    t        | j                  dd      }t        | j                  | j                  |       y)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   s     r   r7  z"ZeroOrOneChoice._add_choice_getterd  s.     T00$=	!!4??I>r!   c                X     d fd}d|_          j                   j                  |       y)zSAdd a ``_remove_eg_x()`` method to the element class for this choice
        group.c                J    j                   D ]  }| j                  |        y r2   )_member_nsptagnamesr/  )r   tagnamer*   s     r   _remove_choice_groupz@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groupo  s$    33 (w'(r!   z9Remove the current choice group child element if present.Nr   )rU   r    _remove_choice_group_method_name)r*   r@  s   ` r   r8  z"ZeroOrOneChoice._add_group_removerk  s+    	( (c$4@@BVWr!   c                "     d fd}d|_         |S )r  c                6     | j                   j                   S r2   )first_child_found_inr>  r   s    r   get_group_member_elementz@ZeroOrOneChoice._choice_getter.<locals>.get_group_member_element{  s    +3++T-E-EFFr!   zbReturn the child element belonging to this element group, or |None| if no member child is present.r   )rU   )r*   rE  s   ` r   r;  zZeroOrOneChoice._choice_getterv  s    
	G4 	!( ('r!   c                T    | j                   D cg c]  }|j                   c}S c c}w )zjSequence of namespace-prefixed tagnames, one for each of the member elements
        of this choice group.)r4  r   )r*   r9  s     r   r>  z#ZeroOrOneChoice._member_nsptagnames  s"     15>f!!>>>s   %c                     d| j                   z  S r   r   r   s    r   rA  z0ZeroOrOneChoice._remove_choice_group_method_name  r   r!   r  )r5  zSequence[Choice]r   r  r   )rR   rS   rT   rU   rm   rf   r7  r8  r   r;  r   r>  rA  r   r   s   @r   rd   rd   T  sY    &"?	X ( ( ? ?
 . .r!   rd   c                  f     e Zd ZdZd Zd	dZd
dZddZedd       Z	d fdZ
edd       Z xZS )r   zvEffective base class for all custom element classes.

    Adds standardized behavior to all classes in one place.
    c                `    d| j                   j                  | j                  t        |       fz  S )Nz<%s '<%s>' at 0x%0x>)rv   rR   _nsptagidr   s    r   __repr__zBaseOxmlElement.__repr__  s/    %NN##LLtH)
 
 	
r!   c                R    |D ]"  }| j                  t        |            }| |c S  y)z9First child with tag in `tagnames`, or None if not found.N)r   r   )r*   tagnamesr?  r   s       r   rD  z$BaseOxmlElement.first_child_found_in  s3     	GIIbk*E 	 r!   c                p     | j                   | }||j                  |       |S | j                  |       |S r2   )rD  addpreviousappend)r*   elmrN  	successors       r   r   z%BaseOxmlElement.insert_element_before  sB    -D--x8	 !!#& 
 KK
r!   c                v    |D ]4  }| j                  t        |            }|D ]  }| j                  |        6 y)z>Remove child elements with tagname (e.g. "a:p") in `tagnames`.N)r   r   remove)r*   rN  r?  matchingr   s        r   r/  zBaseOxmlElement.remove_all  s>     	#G||BwK0H! #E"#	#r!   c                    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   s    r   r   zBaseOxmlElement.xml  s     %T**r!   c                .    t         |   |t              S )zOverride of `lxml` _Element.xpath() method.

        Provides standard Open XML namespace mapping (`nsmap`) in centralized location.
        )
namespaces)rq   xpathr   )r*   	xpath_strrv   s     r   rZ  zBaseOxmlElement.xpath  s    
 w}Y5}99r!   c                @    t        j                  | j                        S r2   )r   from_clark_namer   r   s    r   rJ  zBaseOxmlElement._nsptag  s    #33DHH==r!   )rN  r%   rP   z_Element | None)rR  r   rN  r%   )rN  r%   rP   r   )rP   r%   )r[  r%   rP   r   )rR   rS   rT   rU   rL  rD  r   r/  r   r   rZ  rJ  r   r   s   @r   r   r     sI    

# + +: > >r!   r   )	metaclass)r   r   )0rU   
__future__r   rV   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   rZ   typer\   ro   r`   ra   r   r  r^   r_   rb   rc   rd   r   rY   r!   r   <module>ri     s    F " 	
 
 
  , 0 8 8 $*4:) :)z T]7d 7$(< (<V< <~, ,^^+ ^+B84 84v!% !8(! ((" ((1! (1V8.' 8.x5>e''? 5>r!   