HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/enum/__pycache__/base.cpython-310.pyc
o

$we5�@s�dZddlmZddlZddlZddlmZmZmZm	Z	ddl
mZe	ddd�ZGd	d
�d
e
ej�ZGdd�de
ej�ZGdd
�d
�ZdS)z4Base classes and other objects used by enumerations.�)�annotationsN)�Any�Dict�Type�TypeVar)�Self�_T�BaseXmlEnum)�boundc@s"eZdZdZddd�Zdd	�Zd
S)�BaseEnumz�Base 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�strcCs t�||�}||_|��|_|S�N)r
�__new__�_value_�strip�__doc__)�clsrr�self�r�G/home/arjun/projects/env/lib/python3.10/site-packages/docx/enum/base.pyrs
zBaseEnum.__new__cC�|j�d|j�d�S�zEThe symbolic name and string value of this member, e.g. 'MIDDLE (3)'.z (�)��name�value�rrrr�__str__�zBaseEnum.__str__N)rr
rr)�__name__�
__module__�__qualname__rrr rrrrrs
rc@sHeZdZUdZded<ddd�Zd	d
�Zeddd��Zeddd��Z	dS)r	z�Base 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.
    r�	xml_valuerr
rcCs&t�||�}||_||_|��|_|Sr)r
rrr%rr)rrr%rrrrrr)s

zBaseXmlEnum.__new__cCrrrrrrrr 0r!zBaseXmlEnum.__str__�
str | None�returnrcs:t�fdd�|D�d�}|durt|j�d��d���|S)z�Enumeration member corresponding to XML attribute value `xml_value`.

        Example::

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

        c3s�|]
}|j�kr|VqdSr�r%��.0�memberr(rr�	<genexpr>>s�z'BaseXmlEnum.from_xml.<locals>.<genexpr>Nz has no XML mapping for '�')�next�
ValueErrorr")rr%r+rr(r�from_xml4s
zBaseXmlEnum.from_xmlr�Type[_T]r�int | _T | NonecCs
||�jS)z@XML value of this enum member, generally an XML attribute value.r()rrrrr�to_xmlCs
zBaseXmlEnum.to_xmlN)rr
r%rrr)r%r&r'r)rr1rr2r'r&)
r"r#r$r�__annotations__rr �classmethodr0r3rrrrr	 s

c@s`eZdZdZddd�Zedd	��Zed
d��Zddd�Zedd��Z	edd��Z
edd��ZdS)�DocsPageFormatterz�Generate an .rst doc page for an enumeration.

    Formats a RestructuredText documention page (string) for the enumeration class parts
    passed to the constructor. An immutable one-shot service object.
    �clsnamer�clsdict�Dict[str, Any]cCs||_||_dSr)�_clsname�_clsdict)rr7r8rrr�__init__Rs
zDocsPageFormatter.__init__cCs d}|j|j|j|jf}||S)zyThe 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�
componentsrrr�page_strVs�zDocsPageFormatter.page_strcCs@z|jd}Wntyd}Ynw|durdSt�|���S)z?Docstring of the enumeration, formatted for documentation page.r�N)r;�KeyError�textwrap�dedentr)r�
cls_docstringrrrr?es�zDocsPageFormatter._intro_textr+�BaseEnum | BaseXmlEnumcCs>|jdusJ�t�|j���}tj|dddd�}d|j|fS)ztReturn an individual member definition formatted as an RST glossary entry,
        wrapped to fit within 78 columns.N�Nz    )�width�initial_indent�subsequent_indentz%s
%s
)rrFrGr�fillr)rr+�member_docstringrrr�_member_defrs�zDocsPageFormatter._member_defcs&�jd}�fdd�|D�}d�|�S)zgA single string containing the aggregated member definitions section of the
        documentation page.�__members__cs g|]}|jdur��|��qSr)rrPr)rrr�
<listcomp>�sz2DocsPageFormatter._member_defs.<locals>.<listcomp>�
)r;�join)r�members�member_defsrrrr@s


�
zDocsPageFormatter._member_defscCs
|jdS)z,The Microsoft API name for this enumeration.�__ms_name__)r;rrrrr=�s
zDocsPageFormatter._ms_namecCs dt|j�d}d|j|fS)z�The title for the documentation page, formatted as code (surrounded in
        double-backtics) and underlined with '=' characters.�=�z	``%s``
%s)�lenr:)r�title_underscorerrrr>�szDocsPageFormatter._page_titleN)r7rr8r9)r+rI)r"r#r$rr<�propertyrCr?rPr@r=r>rrrrr6Ks




	
r6)r�
__future__r�enumrF�typingrrrr�typing_extensionsrrr
�Enumrr	r6rrrr�<module>s+