a
     ˜ëj==  ã                   @   s  d Z ddl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mZmZ ddlmZ ddlmZmZmZmZmZmZ g d¢ZdZdZG d	d
„ d
eƒZG dd„ dƒZeefddddfeeeef ee	d  eee eeeeeeeef gef f  edœdd„Zd-ee e ee dœdd„Z!eefdddfeeeef eee eeeeeeeef gef f  edœdd„Z"d.eeeeeeeef gef f eedœdd„Z#eee dœd d!„Z$eee dœd"d#„Z%d/ee e&d$œd%d&„Z'ee dœd'd(„Z(ee dœd)d*„Z)eedœd+d,„Z*dS )0z4
emoji.core
~~~~~~~~~~

Core components for emoji.

é    N)ÚAnyÚCallableÚDictÚIteratorÚListÚLiteralÚMatchÚOptionalÚTupleÚ	TypedDictÚUnion)Úunicode_codes)ÚTokenÚ
EmojiMatchÚEmojiMatchZWJÚEmojiMatchZWJNonRGIÚtokenizeÚfilter_tokens)ÚemojizeÚdemojizeÚanalyzeÚconfigÚ
emoji_listÚdistinct_emoji_listÚemoji_countÚreplace_emojiÚis_emojiÚpurely_emojiÚversionr   r   r   r   ú:uB   \w\-&.â€™â€�â€œ()!#*+,/Â«Â»Ì€Ì�Ì‚ÌƒÌ†ÌˆÌŠÌ§Ù‹ÙŽÙ�Ù�Ù“Ù”ã‚™ãƒ»ã‚šÙ•c                   @   s&   e Zd ZU eed< eed< eed< dS )Ú_EmojiListReturnÚemojiÚmatch_startÚ	match_endN)Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__Úint© r*   r*   úI/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/emoji/core.pyr    .   s   
r    c                   @   s:   e Zd ZdZdZdZedeee	 e	df dœdd„ƒZ
dS )	r   zModule-wide configurationTFN)Úlanguagec                 C   s6   t | tƒr| gn| r| ntj}|D ]}t |¡ q"dS )u¿  Load one or multiple languages into memory.
        If no language is specified, all languages will be loaded.

        This makes language data accessible in the :data:`EMOJI_DATA` dict.
        For example to access a French emoji name, first load French with

         ``emoji.config.load_language('fr')``

        and then access it with

         ``emoji.EMOJI_DATA['ðŸ�„']['fr']``

        Available languages are listed in :data:`LANGUAGES`N)Ú
isinstancer'   r   Ú	LANGUAGESÚload_from_json)r,   Ú	languagesÚlangr*   r*   r+   Úload_languageX   s    ÿÿûzconfig.load_language)N)r$   r%   r&   Ú__doc__Údemojize_keep_zwjÚreplace_emoji_keep_zwjÚstaticmethodr   r   r'   r2   r*   r*   r*   r+   r   4   s
   	r   Úen)Ú	text_typeÚ
emoji_type)ÚstringÚ
delimitersÚvariantr,   r   Úhandle_versionÚreturnc              	      s^   t  ˆ¡ t dt ˆ d ¡tt ˆ d ¡f ¡}tt tdœ‡ ‡‡‡‡fdd„}| || ¡S )u/  
    Replace emoji names in a string with Unicode codes.
        >>> import emoji
        >>> print(emoji.emojize("Python is fun :thumbsup:", language='alias'))
        Python is fun ðŸ‘�
        >>> print(emoji.emojize("Python is fun :thumbs_up:"))
        Python is fun ðŸ‘�
        >>> print(emoji.emojize("Python is fun {thumbs_up}", delimiters = ("{", "}")))
        Python is fun ðŸ‘�
        >>> print(emoji.emojize("Python is fun :red_heart:", variant="text_type"))
        Python is fun â�¤
        >>> print(emoji.emojize("Python is fun :red_heart:", variant="emoji_type"))
        Python is fun â�¤ï¸� # red heart, not black heart

    :param string: String contains emoji names.
    :param delimiters: (optional) Use delimiters other than _DEFAULT_DELIMITER. Each delimiter
        should contain at least one character that is not part of a-zA-Z0-9 and ``_-&.()!?#*+,``.
        See ``emoji.core._EMOJI_NAME_PATTERN`` for the regular expression of unsafe characters.
    :param variant: (optional) Choose variation selector between "base"(None), VS-15 ("text_type") and VS-16 ("emoji_type")
    :param language: Choose language of emoji name: language code 'es', 'de', etc. or 'alias'
        to use English aliases
    :param version: (optional) Max version. If set to an Emoji Version,
        all emoji above this version will be ignored.
    :param handle_version: (optional) Replace the emoji above ``version``
        instead of ignoring it. handle_version can be either a string or a
        callable; If it is a callable, it's passed the Unicode emoji and the
        data dict from :data:`EMOJI_DATA` and must return a replacement string
        to be used::

            handle_version('\U0001F6EB', {
                'en' : ':airplane_departure:',
                'status' : fully_qualified,
                'E' : 1,
                'alias' : [':flight_departure:'],
                'de': ':abflug:',
                'es': ':aviÃ³n_despegando:',
                ...
            })

    :raises ValueError: if ``variant`` is neither None, 'text_type' or 'emoji_type'

    z(%s[%s]+%s)r   é   )Úmatchr>   c                    s&  |   d¡tˆ d ƒtˆ d ƒ … }t tt d|¡ t ˆ¡}|d u rR|   d¡S ˆd ur¸tj| d ˆkr¸tˆƒr¤tj|  	¡ }|  
¡ |d< |  ¡ |d< ˆ||ƒS ˆd ur´tˆƒS dS ˆd u sÎdtj| vrÒ|S |d	 d
ksê|d	 dkrö|dd	… }ˆdk�r|d
 S ˆdk�r|d S tdƒ‚d S )Nr?   r   ÚNFKCÚEr"   r#   Ú r<   éÿÿÿÿu   ï¸Žu   ï¸�r8   r9   zDParameter 'variant' must be either None, 'text_type' or 'emoji_type')ÚgroupÚlenr   Úget_emoji_by_nameÚ_DEFAULT_DELIMITERÚunicodedataÚ	normalizeÚ
EMOJI_DATAÚcallableÚcopyÚstartÚendr'   Ú
ValueError)r@   ÚnameZemjZemj_data©r;   r=   r,   r<   r   r*   r+   Úreplace®   s>    $
ÿþü



ÿzemojize.<locals>.replace)	r   r/   ÚreÚcompileÚescapeÚ_EMOJI_NAME_PATTERNr   r'   Úsub)r:   r;   r<   r,   r   r=   ÚpatternrS   r*   rR   r+   r   t   s    3
ÿÿ 'r   FT)r:   Ú	non_emojiÚ
join_emojir>   c                 C   s   t t| dd�| |d�S )a  
    Find unicode emoji in a string. Yield each emoji as a named tuple
    :class:`Token` ``(chars, EmojiMatch)`` or :class:`Token` ``(chars, EmojiMatchZWJNonRGI)``.
    If ``non_emoji`` is True, also yield all other characters as
    :class:`Token` ``(char, char)`` .

    :param string: String to analyze
    :param non_emoji: If True also yield all non-emoji characters as Token(char, char)
    :param join_emoji: If True, multiple EmojiMatch are merged into a single
        EmojiMatchZWJNonRGI if they are separated only by a ZWJ.
    T©Zkeep_zwj©Z
emoji_onlyr[   )r   r   )r:   rZ   r[   r*   r*   r+   r   Ø   s    ÿr   )r:   r;   r,   r   r=   r>   c                    sb   ˆdkrd‰d‰ nd‰ t  ˆ¡ ttdœ‡ ‡‡‡‡fdd„‰t| tjd�}d	 ‡fd
d„|D ƒ¡S )u  
    Replace Unicode emoji in a string with emoji shortcodes. Useful for storage.
        >>> import emoji
        >>> print(emoji.emojize("Python is fun :thumbs_up:"))
        Python is fun ðŸ‘�
        >>> print(emoji.demojize("Python is fun ðŸ‘�"))
        Python is fun :thumbs_up:
        >>> print(emoji.demojize("icode is tricky ðŸ˜¯", delimiters=("__", "__")))
        Unicode is tricky __hushed_face__

    :param string: String contains Unicode characters. MUST BE UNICODE.
    :param delimiters: (optional) User delimiters other than ``_DEFAULT_DELIMITER``
    :param language: Choose language of emoji name: language code 'es', 'de', etc. or 'alias'
        to use English aliases
    :param version: (optional) Max version. If set to an Emoji Version,
        all emoji above this version will be removed.
    :param handle_version: (optional) Replace the emoji above ``version``
        instead of removing it. handle_version can be either a string or a
        callable ``handle_version(emj: str, data: dict) -> str``; If it is
        a callable, it's passed the Unicode emoji and the data dict from
        :data:`EMOJI_DATA` and must return a replacement string  to be used.
        The passed data is in the form of::

            handle_version('\U0001F6EB', {
                'en' : ':airplane_departure:',
                'status' : fully_qualified,
                'E' : 1,
                'alias' : [':flight_departure:'],
                'de': ':abflug:',
                'es': ':aviÃ³n_despegando:',
                ...
            })

    Úaliasr7   TF©Úemoji_matchr>   c                    sº   | j d usJ ‚ˆd urN| j d ˆkrNtˆƒr<ˆ| j|  ¡ ƒS ˆd urHˆS dS nhˆ| j v r°ˆ rŒd| j v rŒˆd | j d d dd…  ˆd  S ˆd | j ˆ dd…  ˆd  S n| jS d S )NrB   rC   r^   r   r?   rD   )ÚdatarL   r!   Ú	data_copy©r`   )Ú_use_aliasesr;   r=   r,   r   r*   r+   Úhandle  s    
$ÿ$zdemojize.<locals>.handler\   rC   c                 3   s.   | ]&}t |jtƒr tˆ |jƒƒn|jV  qd S ©N©r-   Úvaluer   r'   )Ú.0Útoken©re   r*   r+   Ú	<genexpr>3  s   ÿzdemojize.<locals>.<genexpr>)r   r/   r   r'   r   r   r4   Újoin)r:   r;   r,   r   r=   Úmatchesr*   )rd   r;   re   r=   r,   r   r+   r   ì   s    *
þr   rC   rD   )r:   rS   r   r>   c                    sP   t tdœ‡‡fdd„‰ t| tjd�}tjr8t|ddd�}d ‡ fd	d
„|D ƒ¡S )a  
    Replace Unicode emoji in a customizable string.

    :param string: String contains Unicode characters. MUST BE UNICODE.
    :param replace: (optional) replace can be either a string or a callable;
        If it is a callable, it's passed the Unicode emoji and the data dict from
        :data:`EMOJI_DATA` and must return a replacement string to be used.
        replace(str, dict) -> str
    :param version: (optional) Max version. If set to an Emoji Version,
        only emoji above this version will be replaced.
    r_   c                    sp   ˆdkrF| j d usJ ‚| j d ˆkrjtˆ ƒr<ˆ | j|  ¡ ƒS tˆ ƒS n$tˆ ƒr^ˆ | j|  ¡ ƒS ˆ d urjˆ S | jS )NrD   rB   )ra   rL   r!   rb   r'   rc   ©rS   r   r*   r+   re   J  s    
zreplace_emoji.<locals>.handler\   FTr]   rC   c                 3   s.   | ]&}t |jtƒr tˆ |jƒƒn|jV  qd S rf   rg   ©ri   Úmrk   r*   r+   rl   [  s   ÿz replace_emoji.<locals>.<genexpr>)r   r'   r   r   r5   r   rm   )r:   rS   r   rn   r*   )re   rS   r   r+   r   9  s    þr   )r:   r>   c                 C   s   dd„ t | dd�D ƒS )u´   
    Returns the location and emoji in list of dict format.
        >>> emoji.emoji_list("Hi, I am fine. ðŸ˜�")
        [{'match_start': 15, 'match_end': 16, 'emoji': 'ðŸ˜�'}]
    c                 S   s0   g | ](}t |jtƒr|jj|jj|jjd œ‘qS ))r"   r#   r!   )r-   rh   r   rN   rO   r!   rp   r*   r*   r+   Ú
<listcomp>h  s   ûýzemoji_list.<locals>.<listcomp>Fr\   )r   ©r:   r*   r*   r+   r   a  s    
úr   c                 C   s   t dd„ t| ƒD ƒƒ}|S )z0Returns distinct list of emojis from the string.c                 S   s   h | ]}|d  ’qS )r!   r*   )ri   Úer*   r*   r+   Ú	<setcomp>u  ó    z&distinct_emoji_list.<locals>.<setcomp>)Úlistr   )r:   Zdistinct_listr*   r*   r+   r   s  s    r   )r:   Úuniquer>   c                 C   s   |rt t| ƒƒS t t| ƒƒS )zr
    Returns the count of emojis in a string.

    :param unique: (optional) True if count only unique emojis
    )rF   r   r   )r:   rx   r*   r*   r+   r   y  s    r   c                 C   s
   | t jv S )z{
    Returns True if the string is a single emoji, and it is "recommended for
    general interchange" by Unicode.org.
    )r   rK   rs   r*   r*   r+   r   „  s    r   c                 C   s   t dd„ t| dd�D ƒƒS )z¸
    Returns True if the string contains only emojis.
    This might not imply that `is_emoji` for all the characters, for example,
    if the string contains variation selectors.
    c                 s   s   | ]}t |jtƒV  qd S rf   )r-   rh   r   rp   r*   r*   r+   rl   ’  rv   zpurely_emoji.<locals>.<genexpr>T)rZ   )Úallr   rs   r*   r*   r+   r   Œ  s    r   c                    sÐ   | t jv rt j|  d S t  | d¡}|r@|t jv r@t j| d S g ‰ ttttf tdœ‡ fdd„}t| |dd� ˆ r|ˆ d S t| d	d|d
� ˆ r˜ˆ d S t jD ]$}t| |d|d
� ˆ ržˆ d   S qžt	dƒ‚dS )u]  
    Returns the Emoji Version of the emoji.

    See https://www.unicode.org/reports/tr51/#Versioning for more information.
        >>> emoji.version("ðŸ˜�")
        0.6
        >>> emoji.version(":butterfly:")
        3

    :param string: An emoji or a text containing an emoji
    :raises ValueError: if ``string`` does not contain an emoji
    rB   r7   )rt   Ú
emoji_datar>   c                    s   ˆ   |d ¡ dS )NrB   rC   )Úappend)rt   rz   ©r   r*   r+   Úf®  s    zversion.<locals>.frD   ro   r   r^   )r,   r   r=   zNo emoji found in stringN)
r   rK   rG   r'   r   r   r   r   r.   rP   )r:   Zemj_coder}   Z	lang_coder*   r|   r+   r   •  s$    

r   )FT)rC   rD   )F)+r3   rT   rI   Útypingr   r   r   r   r   r   r   r	   r
   r   r   r!   r   Zemoji.tokenizerr   r   r   r   r   r   Ú__all__rH   rW   r    r   r'   Úfloatr   Úboolr   r   r   r   r   r)   r   r   r   r   r*   r*   r*   r+   Ú<module>   sn   4 	Bú

"ùe ÿþû
"úO  ýü(	