
    ,h                        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	m
Z
 erddlmZ  e
dd      Z G d	 d
eej                        Z G d deej                        Z G d d      Zy)z4Base classes and other objects used by enumerations.    )annotationsN)TYPE_CHECKINGAnyDictTypeTypeVar)Self_TBaseXmlEnum)boundc                      e Zd ZdZddZd Zy)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.
    c                j    t         j                  | |      }||_        |j                         |_        |S N)int__new___value_strip__doc__)clsms_api_valuedocstrselfs       P/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/enum/base.pyr   zBaseEnum.__new__   s+    {{3-#||~    c                :    | j                    d| j                   dS zEThe symbolic name and string value of this member, e.g. 'MIDDLE (3)'.z ()namevaluer   s    r   __str__zBaseEnum.__str__       ))Btzzl!,,r   N)r   r   r   str)__name__
__module____qualname__r   r   r#    r   r   r   r      s    -r   r   c                  N    e Zd ZU dZded<   d	dZd Zed
d       Zedd       Z	y)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.
    r%   	xml_valuec                x    t         j                  | |      }||_        ||_        |j	                         |_        |S r   )r   r   r   r+   r   r   )r   r   r+   r   r   s        r   r   zBaseXmlEnum.__new__*   s2    {{3-#"||~r   c                :    | j                    d| j                   dS r   r   r"   s    r   r#   zBaseXmlEnum.__str__1   r$   r   c                l    t        fd| D        d      }|t        | j                   d d      |S )zEnumeration member corresponding to XML attribute value `xml_value`.

        Example::

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

        c              3  B   K   | ]  }|j                   k(  s|  y wr   r+   ).0memberr+   s     r   	<genexpr>z'BaseXmlEnum.from_xml.<locals>.<genexpr>?   s     Q&63C3Cy3PvQs   Nz has no XML mapping for '')next
ValueErrorr&   )r   r+   r2   s    ` r   from_xmlzBaseXmlEnum.from_xml5   s@     QCQSWX>~-FykQRSTTr   c                &     | |      j                   S )z@XML value of this enum member, generally an XML attribute value.r0   )r   r!   s     r   to_xmlzBaseXmlEnum.to_xmlD   s    
 5z###r   N)r   r   r+   r%   r   r%   )r+   
str | Nonereturnr	   )r   zType[_T]r!   zint | _T | Noner;   r:   )
r&   r'   r(   r   __annotations__r   r#   classmethodr7   r9   r)   r   r   r   r   !   s@     N-   $ $r   c                  p    e Zd ZdZd
dZed        Zed        ZddZed        Z	ed        Z
ed        Zy	)DocsPageFormatterzGenerate 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.
    c                     || _         || _        y r   )_clsname_clsdict)r   clsnameclsdicts      r   __init__zDocsPageFormatter.__init__S   s    r   c                l    d}| j                   | j                  | j                  | j                  f}||z  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
componentss      r   page_strzDocsPageFormatter.page_strW   s?     3MM	

 j  r   c                    	 | j                   d   }|yt        j                  |      j	                         S # t        $ r d}Y 3w xY w)z?Docstring of the enumeration, formatted for documentation page.r    )rB   KeyErrortextwrapdedentr   )r   cls_docstrings     r   rI   zDocsPageFormatter._intro_textf   sN    	 MM)4M  }-3355  	M	s   7 AAc                    |j                   J t        j                  |j                         j                         }t        j                  |ddd      }|j
                  d|dS )ztReturn an individual member definition formatted as an RST glossary entry,
        wrapped to fit within 78 columns.N   z    )widthinitial_indentsubsequent_indent
)r   rQ   rR   r   fillr    )r   r2   member_docstrings      r   _member_defzDocsPageFormatter._member_defs   sZ     ~~))#??6>>:@@B#=="%	
 $[[*:;;r   c                    | j                   d   }|D cg c]   }|j                  | j                  |      " }}dj                  |      S c c}w )zgA single string containing the aggregated member definitions section of the
        documentation page.__members__rY   )rB   r    r\   join)r   membersr2   member_defss       r   rJ   zDocsPageFormatter._member_defs   sN     --.>EaFI`t''/aayy%% bs
   AAc                     | j                   d   S )z,The Microsoft API name for this enumeration.__ms_name__)rB   r"   s    r   rG   zDocsPageFormatter._ms_name   s     }}]++r   c                \    dt        | j                        dz   z  }d| j                  d|S )zThe title for the documentation page, formatted as code (surrounded in
        double-backtics) and underlined with '=' characters.=   z``z``
)lenrA   )r   title_underscores     r   rH   zDocsPageFormatter._page_title   s-     #dmm"4q"89#}}.>??r   N)rC   r%   rD   zDict[str, Any])r2   zBaseEnum | BaseXmlEnum)r&   r'   r(   r   rE   propertyrM   rI   r\   rJ   rG   rH   r)   r   r   r?   r?   L   sw      ! ! 
6 
6< & & , , @ @r   r?   )r   
__future__r   enumrQ   typingr   r   r   r   r   typing_extensionsr	   r
   r   Enumr   r   r?   r)   r   r   <module>ro      s\    : "   : :&T'-sDII -$($#tyy ($VF@ F@r   