
    li!i                       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 ddlmZ ddlmZmZ ddlmZ ddlmZ dd	lmZmZmZ dd
lmZ  G d de      Zd*d+dZ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      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)-zPBase and meta classes enabling declarative definition of custom element classes.    )annotationsN)AnyCallableIterableProtocolSequenceTypecast)etree)ElementBase_Element)InvalidXmlError)oxml_parser)NamespacePrefixedTag_nsmapqn)lazypropertyc                  4    e Zd ZdZedd       Zedd       Zy)AttributeTypezInterface for an object that can act as an attribute type.

    An attribute-type specifies how values are transformed to and from the XML "string" value of the
    attribute.
    c                     y)z/Transform an attribute value to a Python value.N )cls	xml_values     P/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/oxml/xmlchemy.pyfrom_xmlzAttributeType.from_xml        	    c                     y)zGTransform a Python value to a str value suitable to this XML attribute.Nr   )r   values     r   to_xmlzAttributeType.to_xml   r   r   N)r   strreturnr   )r   r   r"   r!   )__name__
__module____qualname____doc__classmethodr   r    r   r   r   r   r      s/        r   r   BaseOxmlElementc                z    t        |       }||n|j                  }t        j                  |j                  |      S )a  Return a "loose" lxml element having the tag specified by `nsptag_str`.

    `nsptag_str` must contain the standard namespace prefix, e.g. 'a:tbl'. The resulting element is
    an instance of the custom element class for this tag name if one is defined.
    )nsmap)r   r*   r   makeelement
clark_name)
nsptag_strr*   nsptags      r   OxmlElementr/   #   s7     "*-F&EFLLE""6#4#4EBBr   c                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     r   serialize_for_readingr8   .   s     
 ..94
HCS>r   c                  \    e Zd ZdZ ej
                  d      Zd	dZd	dZd
dZ	ddZ
ddZy)r5   zRProvides string comparison override suitable for serialized XML; 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)
isinstancer!   
splitlineslenzip_eq_elm_strs)selfotherlineslines_otherline
line_others         r   __eq__zXmlString.__eq__B   sp    %%!&&(u:[)) #E; 7 	D*$$T:6	 r   c                &    | j                  |       S N)rF   )r@   rA   s     r   __ne__zXmlString.__ne__N   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_seqQ   s%    
 ;;=hr   c                    | j                  |      \  }}}}| j                  |      \  }}}	}
||k7  ry| j                  |      | j                  |      k7  ry||	k7  ry||
k7  ryy)zTrue if the element in `line_2` is XML-equivalent to the element in `line`.

        In particular, the order of attributes in XML is not significant.
        FT)_parse_linerP   )r@   rD   line_2frontrN   closetextfront_2attrs_2close_2text_2s              r   r?   zXmlString._eq_elm_strsZ   sv    
 %)$4$4T$:!ueT,0,<,<V,D)'6G>>% DNN7$;;G6>r   c                    | j                   j                  |      }|t        d      t        dd      D cg c]  }|j	                  |       c}\  }}}}||||fS c c}w )zUReturn front, attrs, close, text 4-tuple result of parsing XML element string `line`.z0`line` does not match pattern for an XML element      )_xml_elm_line_pattmatch
ValueErrorrangegroup)r@   rD   r_   nrT   rN   rU   rV   s           r   rR   zXmlString._parse_linek   se    ''--d3=OPP=B1a[$IU[[^$I!ueTeUD(( %Js   AN)rA   objectr"   bool)rN   r!   r"   	list[str])rD   r!   rS   r!   r"   re   )rD   r!   )r#   r$   r%   r&   recompiler^   rF   rI   rP   r?   rR   r   r   r   r5   r5   7   s2    \ $$OP
& ")r   r5   c                      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 rH   )
OneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoiceitemsr;   populate_class_members)r   clsnamebasesclsdictdispatchablekeyr   s          r   __init__zMetaOxmlElement.__init__w   sS    
 "--/ 	7JC%.,,S#6	7r   N)ru   r!   rv   ztuple[type, ...]rw   zdict[str, Any])r#   r$   r%   r&   rz   r   r   r   rj   rj   t   s
    (7r   rj   c                  Z    e Zd ZdZd	dZd
dZd Zed        Zedd       Z	edd       Z
y)BaseAttributezQBase class for OptionalAttribute and RequiredAttribute, providing common methods.c                     || _         || _        y rH   )
_attr_name_simple_type)r@   	attr_namesimple_types      r   rz   zBaseAttribute.__init__   s    #'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   rt   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setattrr   r   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:)r~   r   r@   s    r   _clark_namezBaseAttribute._clark_name   s'    $//!doo&&r   c                    t        d      )JCallable suitable for the "get" side of the attribute property descriptor.$must be implemented by each subclassNotImplementedErrorr   s    r   r   zBaseAttribute._getter        ""HIIr   c                    t        d      )JCallable suitable for the "set" side of the attribute property descriptor.r   r   r   s    r   r   zBaseAttribute._setter   r   r   N)r   r!   r   type[AttributeType]r   Type[BaseOxmlElement]r   r!   r"   z Callable[[BaseOxmlElement], Any]r"   z&Callable[[BaseOxmlElement, Any], None])r#   r$   r%   r&   rz   rt   r   r   r   r   r   r   r   r   r|   r|      sT    [("?  
 J J J Jr   r|   c                  Z     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 )
rn   zDefines 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.
    c                <    t         t        |   ||       || _        y rH   )superrn   rz   _default)r@   r   r   default	__class__s       r   rz   zOptionalAttribute.__init__   s    /	;Gr   c                N    | j                   j                  d| j                  dS )s
        Return the string to use as the ``__doc__`` attribute of the property
        for this attribute.
         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   r#   r~   r   s    r   
_docstringzOptionalAttribute._docstring   s#       ))4??<	
r   c                6     d fd} j                   |_        |S )r   c                    | j                  j                        }|j                  S j                  j	                  |      S rH   )getr   r   r   r   objattr_str_valuer@   s     r   get_attr_valuez1OptionalAttribute._getter.<locals>.get_attr_value   s>     WWT%5%56N%}}$$$--n==r   r   r(   r"   r   r   r&   r@   r   s   ` r   r   zOptionalAttribute._getter   s    	> "&r   c                     d fd}|S )r   c                    |j                   k(  r0j                  | j                  v r| j                  j                  = y j                  j	                  |      }| j                  j                  |       y rH   )r   r   attribr   r    setr   r   	str_valuer@   s      r   set_attr_valuez1OptionalAttribute._setter.<locals>.set_attr_value   sb     %##szz1

4#3#34))007IGGD$$i0r   r   r(   r   r   r"   Noner   r@   r   s   ` r   r   zOptionalAttribute._setter   s    	1 r   rH   )r   r!   r   r   r   r   r   r   )
r#   r$   r%   r&   rz   r   r   r   r   __classcell__r   s   @r   rn   rn      sI      

 

 
 
  r   rn   c                  D    e Zd ZdZedd       Zed        Zedd       Zy)ro   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                6     d fd} j                   |_        |S )r   c                    | j                  j                        }|%t        dj                  d| j                        j
                  j                  |      S )Nz
required 'z#' attribute not present on element )r   r   r   r~   tagr   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                N    | j                   j                  d| j                  dS )r   r   z`` attribute.r   r   s    r   r   zRequiredAttribute._docstring   s$     &&OO
 	
r   c                     d fd}|S )r   c                t    j                   j                  |      }| j                  j                  |       y rH   )r   r    r   r   r   s      r   r   z1RequiredAttribute._setter.<locals>.set_attr_value  s-    ))007IGGD$$i0r   r   r   r   s   ` r   r   zRequiredAttribute._setter
  s    	1 r   Nr   r   )r#   r$   r%   r&   r   r   r   r   r   r   r   ro   ro      sC       
 
  r   ro   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d
Zedd       Zedd       Zed        Zedd       Zed        Zed        Z xZS )_BaseChildElementzBase class for the child element classes corresponding to varying cardinalities.

    Subclasses include ZeroOrOne and ZeroOrMore.
    c                F    t         t        |           || _        || _        y rH   )r   r   rz   _nsptagname_successors)r@   
nsptagname
successorsr   s      r   rz   z_BaseChildElement.__init__  s!    /1%%r   c                     || _         || _        y)zFBaseline behavior for adding the appropriate methods to `element_cls`.N)r   r   r   s      r   rt   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 rH   )getattr_new_method_namers   r   _insert_method_name)r   rN   
new_methodchildry   r   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(   rN   r   )r   r&   _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.

        This method 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   r&   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)zAdd a read-only `{prop_name}` property to the parent element class.

        The property locates and returns this child element or `None` if not present.
        N)r   r   r   r   r   r   s     r   _add_getterz_BaseChildElement._add_getterC  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 rH   )insert_element_beforer   r   r   r@   s     r   _insert_childz6_BaseChildElement._add_inserter.<locals>._insert_childO  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   r&   r   r   )r@   r   s   ` r   _add_inserterz_BaseChildElement._add_inserterL  s;    	
)+/+;+;< 	 	433]Cr   c                ~    | j                    d}t        | j                  dd      }t        | j                  ||       y)z
        Add a read-only ``{prop_name}_lst`` property to the element class to
        retrieve a list of child elements matching this type.
        _lstN)r   r   _list_getterr   r   )r@   r   r   s      r   _add_list_getterz"_BaseChildElement._add_list_getterY  s;    
 't,	T..d;	!!9i8r   c                     d| j                   z  S )Nz_add_%sr   r   s    r   r   z"_BaseChildElement._add_method_nameb      4??**r   c                `    t        | j                  |      ryt        | j                  ||       y)zSAdd `method` to the target class as `name`, unless `name` is already defined there.N)hasattrr   r   )r@   namemethods      r   r   z_BaseChildElement._add_to_classf  s'    4$$d+!!40r   c                     d fd}|S )zSCallable that creates a new, empty element of the child type, having no attributes.c                .    t        j                        S rH   )r/   r   r   r@   s    r   new_child_elementz5_BaseChildElement._creator.<locals>.new_child_elementp  s    t//00r   r   r(   r   )r@   r   s   ` r   r   z_BaseChildElement._creatorl  s    	1 ! r   c                <     d fd}d j                   z  |_        |S )zCallable 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 rH   )findr   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(   r"   BaseOxmlElement | Noner   r&   r@   r   s   ` r   r   z_BaseChildElement._getteru  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 )zCCallable suitable for the "get" side of a list property descriptor.c                `    t        d| j                  t        j                                    S )Nlist[BaseOxmlElement])r
   findallr   r   r   s    r   get_child_element_listz>_BaseChildElement._list_getter.<locals>.get_child_element_list  s%    /R@P@P=Q1RSSr   zPA list containing each of the ``<%s>`` child elements, in the order they appear.)r   r(   r"   r  r  )r@   r	  s   ` r   r   z_BaseChildElement._list_getter  s,    	T "&"2"23 	& &%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   r   )r   r!   r   Sequence[str]r   )r   r!   r   zCallable[..., Any]r"   z,Callable[[BaseOxmlElement], BaseOxmlElement])r"   z3Callable[[BaseOxmlElement], BaseOxmlElement | None])r"   z2Callable[[BaseOxmlElement], list[BaseOxmlElement]])r#   r$   r%   r&   rz   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   s   @r   r   r     s    
&
$
>$
;?D9 + +1 ! ! ! ! . . 
& 
& . . + +r   r   c                  l    e Zd ZdZed        Z	 	 	 	 	 	 d	dZd
dZed        Ze	d        Z
e	d        Zy)ChoicezVDefines a child element belonging to a group, only one of which may appear as a child.c                    | j                   S rH   )r   r   s    r   r   zChoice.nsptagname  s    r   c                    || _         || _        || _        | j                          | j	                          | j                          | j                          | j                          yz-Add the appropriate methods to `element_cls`.N)r   _group_prop_namer   r   r   r   r   _add_get_or_change_to_method)r@   r   group_prop_namer   s       r   rt   zChoice.populate_class_members  sV     ( /%))+r   c                r     d fd}d j                   z  |_         j                   j                  |       y)zPAdd a `get_or_change_to_x()` method to the element class for this child element.c                    t        | j                        }||S t        | j                        } |        t        | j                        } |       }|S rH   )r   r   _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   r&   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 )zW
        Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
        r   r\   r   N)r   index)r@   starts     r   r   zChoice._prop_name  sE    
 $"""$$**3/!3EE''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  r"   r   )r#   r$   r%   r&   r   r   rt   r  r   r   r  r  r   r   r   r  r    sv    `   ,0,CF,Ta,W$ ( ( 7 7 4 4r   r  c                  B     e Zd ZdZd fdZd fdZedd       Z xZS )rl   z5Defines a required child element for MetaOxmlElement.c                .    t         t        |   |d       y )Nr   )r   rl   rz   )r@   r   r   s     r   rz   zOneAndOnlyOne.__init__  s    mT+J;r   c                N    t         t        |   ||       | j                          yr   )r   rl   rt   r   r@   r   r   r   s      r   rt   z$OneAndOnlyOne.populate_class_members  s"     	mT9+yQr   c                <     d fd}d j                   z  |_        |S )z@Callable 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"   r(   r  r  s   ` r   r   zOneAndOnlyOne._getter  s%    	 %GIYIY$Y!  r   )r   r!   r   r  )	r#   r$   r%   r&   rz   rt   r   r   r   r   s   @r   rl   rl     s$    ?< ! !r   rl   c                  <     e Zd ZdZd fdZddZed        Z xZS )rm   zUDefines a repeating child element for MetaOxmlElement that must appear at least once.c                    t         t        |   ||       | j                          | j	                          | j                          | j                          | j                          t        ||       y)z-Add the appropriate methods to *element_cls*.N)	r   rm   rt   r   r   r   r   _add_public_adderdelattrr)  s      r   rt   z OneOrMore.populate_class_members  sX    i5k9M Y'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 rH   )r   r   )r   private_add_methodr   r@   s      r   	add_childz.OneOrMore._add_public_adder.<locals>.add_child  s#    !(d.C.C!D&(ELr   r   Nr,  )r   r&   r   _public_add_method_name)r@   r4  s   ` r   r/  zOneOrMore._add_public_adder  s;    	#%)%5%56 	 	477Cr   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   r5  z!OneOrMore._public_add_method_name  s     $//))r   r   r%  )	r#   r$   r%   r&   rt   r/  r   r5  r   r   s   @r   rm   rm     s%    _(D * *r   rm   c                  $     e Zd ZdZd fdZ xZS )rp   zJ
    Defines an optional repeating child element for MetaOxmlElement.
    c                    t         t        |   ||       | j                          | j	                          | j                          | j                          t        ||       yr   )r   rp   rt   r   r   r   r   r0  r)  s      r   rt   z!ZeroOrMore.populate_class_members"  sN     	j$6{INY'r   r   )r#   r$   r%   r&   rt   r   r   s   @r   rp   rp     s    	( 	(r   rp   c                  @     e Zd ZdZd fdZd Zd Zed        Z xZ	S )rq   z6Defines an optional child element for MetaOxmlElement.c                    t         t        |   ||       | j                          | j	                          | j                          | j                          | j                          | j                          yr  )	r   rq   rt   r   r   r   r   _add_get_or_adder_add_removerr)  s      r   rt   z ZeroOrOne.populate_class_members1  sZ    i5k9M r   c                r     d fd}d j                   z  |_         j                   j                  |       y)zKAdd a `.get_or_add_x()` method to the element class for this child element.c                r    t        | j                        }|t        | j                        } |       }|S rH   )r   r   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   r&   r   _get_or_add_method_name)r@   r?  s   ` r   r;  zZeroOrOne._add_get_or_adder;  s;    	 M$  	4779IJr   c                t     d fd}d j                    d|_         j                   j                  |       y)zHAdd a `._remove_x()` method to the element class for this child element.c                <    | j                  j                         y rH   )
remove_allr   r   s    r   _remove_childz-ZeroOrOne._add_remover.<locals>._remove_childM  s    NN4++,r   zRemove all `z` child elements.Nr   r(   r"   r   )r   r&   r   r  )r@   rD  s   ` r   r<  zZeroOrOne._add_removerJ  s9    	- #/t/?/?.@@Q R433]Cr   c                     d| j                   z  S )Nzget_or_add_%sr   r   s    r   r@  z!ZeroOrOne._get_or_add_method_nameS  s    00r   r   )
r#   r$   r%   r&   rt   r;  r<  r   r@  r   r   s   @r   rq   rq   .  s+    @KD 1 1r   rq   c                  l     e Zd ZdZd	d
dZd fdZd Zd Zed        Z	e
dd       Ze
d        Z xZS )rr   zOAn `EG_*` element group where at most one of its members may appear as a child.c                D    t        |      | _        t        |      | _        y rH   )tuple_choicesr   )r@   choicesr   s      r   rz   zZeroOrOneChoice.__init__[  s    g ,r   c                    t         t        |   ||       | j                          | j                  D ])  }|j                  || j
                  | j                         + | j                          yr  )r   rr   rt   _add_choice_getterrJ  r   r   _add_group_remover)r@   r   r   choicer   s       r   rt   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.

        The property returns the present member of this group, or |None| if none are present.
        N)r   _choice_getterr   r   r   r   s     r   rM  z"ZeroOrOneChoice._add_choice_getterg  s.    
 T00$=	!!4??I>r   c                X     d fd}d|_          j                   j                  |       y)zJAdd a `._remove_eg_x()` method to the element class for this choice group.c                J    j                   D ]  }| j                  |        y rH   )_member_nsptagnamesrC  )r   tagnamer@   s     r   _remove_choice_groupz@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groups  s$    33 (w'(r   z9Remove the current choice group child element if present.NrE  )r&   r    _remove_choice_group_method_name)r@   rV  s   ` r   rN  z"ZeroOrOneChoice._add_group_removerp  s+    	( (c$4@@BVWr   c                "     d fd}d|_         |S )zj
        Return a function object suitable for the "get" side of the property
        descriptor.
        c                J    t        d | j                  j                         S )Nr   )r
   first_child_found_inrT  r   s    r   get_group_member_elementz@ZeroOrOneChoice._choice_getter.<locals>.get_group_member_element  s)    (*B#*B*BDD\D\*] r   zbReturn the child element belonging to this element group, or |None| if no member child is present.r   )r&   )r@   r[  s   ` r   rQ  zZeroOrOneChoice._choice_getterz  s    	4 	!( ('r   c                T    | j                   D cg c]  }|j                   c}S c c}w )zUSequence of namespace-prefixed tagnames, one for each member element of choice group.)rJ  r   )r@   rO  s     r   rT  z#ZeroOrOneChoice._member_nsptagnames  s"     15>f!!>>>s   %c                     d| j                    S )z!Function-name for choice remover._remove_r   r   s    r   rW  z0ZeroOrOneChoice._remove_choice_group_method_name  s     $//*++r   r  )rK  zIterable[Choice]r   zIterable[str]r   )r"   rf   )r#   r$   r%   r&   rz   rt   rM  rN  r   rQ  r   rT  rW  r   r   s   @r   rr   rr   X  sW    Y-"?X ( (" ? ? , ,r   rr   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>)r   r#   _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@   tagnamesrU  r   s       r   rZ  z$BaseOxmlElement.first_child_found_in  s3     	GIIbk*E 	 r   c                p     | j                   | }||j                  |       |S | j                  |       |S rH   )rZ  addpreviousappend)r@   elmre  	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@   re  rU  matchingr   s        r   rC  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.
        )r8   r   s    r   r7   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)r   xpathr   )r@   	xpath_strr   s     r   rq  zBaseOxmlElement.xpath  s    
 w}Y6}::r   c                @    t        j                  | j                        S rH   )r   from_clark_namer   r   s    r   ra  zBaseOxmlElement._nsptag  s    #33DHH==r   )re  r!   r"   z_Element | None)ri  r   re  r!   )re  r!   r"   r   )r"   r!   )rr  r!   r"   r   )r#   r$   r%   r&   rc  rZ  r   rC  r   r7   rq  ra  r   r   s   @r   r(   r(     sI    

# + +; > >r   )	metaclassrH   )r-   r!   r*   zdict[str, str] | Noner"   r(   )r6   r   )-r&   
__future__r   rg   typingr   r   r   r   r   r	   r
   lxmlr   
lxml.etreer   r   pptx.excr   	pptx.oxmlr   pptx.oxml.nsr   r   r   	pptx.utilr   r   r/   r8   r!   r5   typerj   r|   rn   ro   r   r  rl   rm   rp   rq   rr   r(   r   r   r   <module>r     s    V " 	 J J J  , $ ! 9 9 "H $C:) :)z7d 7$(J (JV3 3l+ +\G+ G+T84 84v!% !:#*! #*L(" ("'1! '1T<,' <,@5>e''? 5>r   