o
    7 h                     @  s   d Z ddlmZ ddlZddlZddlmZmZmZm	Z	 er$ddl
mZ e	dddZG d	d
 d
eejZG dd deejZG dd deZdS )z4Base classes and other objects used by enumerations.    )annotationsN)TYPE_CHECKINGAnyTypeTypeVar)Self_TBaseXmlEnum)boundc                   @  s"   e Zd ZdZdddZdd	 Zd
S )BaseEnumzBase class for Enums that do not map XML attr values.

    The enum's value will be an integer, corresponding to the integer assigned the
    corresponding member in the MS API enum of the same name.
    ms_api_valueintdocstrstrc                 C  s    t | |}||_| |_|S N)r   __new___value_strip__doc__)clsr   r   self r   V/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/enum/base.pyr      s   
zBaseEnum.__new__c                 C     | j  d| j dS zEThe symbolic name and string value of this member, e.g. 'MIDDLE (3)'.z ()namevaluer   r   r   r   __str__      zBaseEnum.__str__N)r   r   r   r   )__name__
__module____qualname__r   r   r    r   r   r   r   r      s    
r   c                   @  sV   e Zd ZU dZded< ddd	Zd
d ZedddZedddZ	edddZ
dS )r	   zBase class for Enums that also map XML attr values.

    The enum's value will be an integer, corresponding to the integer assigned the
    corresponding member in the MS API enum of the same name.
    
str | None	xml_valuer   r   r   r   c                 C  s&   t | |}||_||_| |_|S r   )r   r   r   r&   r   r   )r   r   r&   r   r   r   r   r   r   *   s
   
zBaseXmlEnum.__new__c                 C  r   r   r   r   r   r   r   r    1   r!   zBaseXmlEnum.__str__returnr   c                   sD    rt  fdd| D dnd}|du r t| j dt  |S )a  Enumeration member corresponding to XML attribute value `xml_value`.

        Raises `ValueError` if `xml_value` is the empty string ("") or is not an XML attribute
        value registered on the enumeration. Note that enum members that do not correspond to one
        of the defined values for an XML attribute have `xml_value == ""`. These
        "return-value only" members cannot be automatically mapped from an XML attribute value and
        must be selected explicitly by code, based on the appropriate conditions.

        Example::

            >>> WD_PARAGRAPH_ALIGNMENT.from_xml("center")
            WD_PARAGRAPH_ALIGNMENT.CENTER

        c                 3  s    | ]
}|j  kr|V  qd S r   r&   .0memberr(   r   r   	<genexpr>G   s    z'BaseXmlEnum.from_xml.<locals>.<genexpr>Nz has no XML mapping for )next
ValueErrorr"   repr)r   r&   r+   r   r(   r   from_xml5   s   zBaseXmlEnum.from_xmlr   Type[_T]r   int | _Tc                 C  s.   | |}|j }|st| j d|j d|S )z@XML value of this enum member, generally an XML attribute value..z has no XML representation)r&   r.   r"   r   )r   r   r+   r&   r   r   r   to_xmlQ   s
   zBaseXmlEnum.to_xmlr   c                 C  s"   || vrt | d| j ddS )z9Raise |ValueError| if `value` is not an assignable value.z not a member of z enumerationN)r.   r"   )r   r   r   r   r   validate\   s   zBaseXmlEnum.validateN)r   r   r&   r%   r   r   )r&   r   r'   r   )r   r1   r   r2   r'   r   )r   r1   r   r   )r"   r#   r$   r   __annotations__r   r    classmethodr0   r4   r5   r   r   r   r   r	   !   s   
 

c                   @  s`   e Zd ZdZdddZedd	 Zed
d ZdddZedd Z	edd Z
edd ZdS )DocsPageFormatterzHFormats a reStructuredText documention page (string) for an enumeration.clsnamer   clsdictdict[str, Any]c                 C  s   || _ || _d S r   )_clsname_clsdict)r   r9   r:   r   r   r   __init__f   s   
zDocsPageFormatter.__init__c                 C  s    d}| j | j| j| jf}|| S )z
        The RestructuredText documentation page for the enumeration. This is
        the only API member for the class.
        z.. _%s:

%s

%s

----

%s)_ms_name_page_title_intro_text_member_defs)r   tmpl
componentsr   r   r   page_strj   s   zDocsPageFormatter.page_strc                 C  s@   z| j d }W n ty   d}Y nw |du rdS t| S )zr
        The docstring of the enumeration, formatted for use at the top of the
        documentation page
        r    N)r=   KeyErrortextwrapdedentr   )r   Zcls_docstringr   r   r   rA   y   s   zDocsPageFormatter._intro_textr+   BaseEnum | BaseXmlEnumc                 C  s4   t |jpd }t j|dddd}d|j|f S )zReturn an individual member definition formatted as an RST glossary entry.

        Output is wrapped to fit within 78 columns.
        rF   N   z    )widthinitial_indentsubsequent_indentz%s
%s
)rH   rI   r   r   fillr   )r   r+   Zmember_docstringr   r   r   _member_def   s   zDocsPageFormatter._member_defc                   s&    j d } fdd|D }d|S )zx
        A single string containing the aggregated member definitions section
        of the documentation page
        __members__c                   s    g | ]}|j d ur |qS r   )r   rP   r)   r   r   r   
<listcomp>   s     z2DocsPageFormatter._member_defs.<locals>.<listcomp>
)r=   join)r   membersZmember_defsr   r   r   rB      s   

zDocsPageFormatter._member_defsc                 C  s
   | j d S )z=
        The Microsoft API name for this enumeration
        Z__ms_name__)r=   r   r   r   r   r?      s   
zDocsPageFormatter._ms_namec                 C  s    dt | jd  }d| j|f S )z
        The title for the documentation page, formatted as code (surrounded
        in double-backtics) and underlined with '=' characters
        =   z	``%s``
%s)lenr<   )r   Ztitle_underscorer   r   r   r@      s   zDocsPageFormatter._page_titleN)r9   r   r:   r;   )r+   rJ   )r"   r#   r$   r   r>   propertyrE   rA   rP   rB   r?   r@   r   r   r   r   r8   c   s    




	
r8   )r   
__future__r   enumrH   typingr   r   r   r   typing_extensionsr   r   r   Enumr   r	   objectr8   r   r   r   r   <module>   s    B