Ë
    Fü´jZ  ã                  ó–   — d 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 erddlmZ ddlZdd	lmZ  G d
„ de«      Z G d„ d«      Zy)zProvide the Emoji class.é    )Úannotations)ÚTYPE_CHECKINGÚAny)ÚAPI_PATH)ÚClientException)Ú
RedditBase)ÚIteratorN)Úmodelsc                  ó†   ‡ — e Zd ZdZdZdˆ fd„Zdd„Z	 d	 	 	 	 	 	 	 	 	 dˆ fd„Zdˆ fd„Zdd„Z	dddd	œ	 	 	 	 	 	 	 dd
„Z
ˆ xZS )ÚEmojia­  An individual :class:`.Emoji` object.

    .. include:: ../../typical_attributes.rst

    ====================== =================================================
    Attribute              Description
    ====================== =================================================
    ``mod_flair_only``     Whether the emoji is restricted for mod use only.
    ``name``               The name of the emoji.
    ``post_flair_allowed`` Whether the emoji may appear in post flair.
    ``url``                The URL of the emoji image.
    ``user_flair_allowed`` Whether the emoji may appear in user flair.
    ====================== =================================================

    Únamec                óî   •— t        |t        «      r|t        | «      k(  S t        || j                  «      r2t        | «      t        |«      k(  xr |j                  | j                  k(  S t        ‰| �  |«      S )z5Return whether the other instance equals the current.)Ú
isinstanceÚstrÚ	__class__Ú	subredditÚsuperÚ__eq__)ÚselfÚotherr   s     €úV/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/emoji.pyr   zEmoji.__eq__%   s^   ø€ ä�eœSÔ!ØœC ›IÑ%Ð%Ü�e˜TŸ^™^Ô,Ü�t“9¤ E£
Ñ*ÒP¨u¯©À$Ç.Á.Ñ/PÐPÜ‰w‰~˜eÓ$Ð$ó    c                ó–   — t        | j                  j                  «      t        t        | «      «      z  t        | j                  «      z  S )z(Return the hash of the current instance.)Úhashr   Ú__name__r   r   )r   s    r   Ú__hash__zEmoji.__hash__-   s2   € ä�D—N‘N×+Ñ+Ó,¬t´C¸³I«Ñ>ÄÀdÇnÁnÓAUÑUÐUr   Nc                óD   •— || _         || _        t        ‰| �  ||¬«       y)z'Initialize an :class:`.Emoji` instance.©Ú_dataN)r   r   r   Ú__init__)r   Úredditr   r   r   r   s        €r   r    zEmoji.__init__1   s%   ø€ ð ˆŒ	Ø"ˆŒÜ‰Ñ˜ uÐÕ-r   c                ó$  •— | j                   j                  D ]P  }|j                  | j                  k(  sŒ| j                  j	                  |j                  «       t
        ‰| �  «         y  d| j                   › d| j                  › �}t        |«      ‚)Nzr/z does not have the emoji )r   Úemojir   Ú__dict__Úupdater   Ú_fetchr   )r   r#   Úmsgr   s      €r   r&   zEmoji._fetch=   sx   ø€ Ø—^‘^×)Ñ)ò 	ˆEØ�z‰z˜TŸY™YÓ&Ø—‘×$Ñ$ U§^¡^Ô4Ü‘‘Ô Ùð		ð
 �4—>‘>Ð"Ð";¸D¿I¹I¸;ÐGˆÜ˜cÓ"Ð"r   c                ó–   — t         d   j                  | j                  | j                  ¬«      }| j                  j                  |«       y)zÙDelete an emoji from this subreddit by :class:`.Emoji`.

        To delete ``"emoji"`` as an emoji on r/test try:

        .. code-block:: python

            reddit.subreddit("test").emoji["emoji"].delete()

        Úemoji_delete)Ú
emoji_namer   N)r   Úformatr   r   Ú_redditÚdelete)r   Úurls     r   r-   zEmoji.deleteF   s8   € ô �~Ñ&×-Ñ-¸¿¹ÈdÏnÉnÐ-Ó]ˆØ�‰×Ñ˜CÕ r   ©Úmod_flair_onlyÚpost_flair_allowedÚuser_flair_allowedc               óÞ  — t        «       }dD �ci c]  }|||   “Œ
 }}t        d„ |j                  «       D «       «      rd}t        |«      ‚d| j                  i}|j                  «       D ]  \  }}	|	€t        | |«      }	|	||<   Œ t        d   j                  | j                  ¬«      }
| j                  j                  |
|¬«       |j                  «       D ]  \  }}	t        | ||	«       Œ yc c}w )	a�  Update the permissions of an emoji in this subreddit.

        :param mod_flair_only: Indicate whether the emoji is restricted to mod use only.
            Respects pre-existing settings if not provided.
        :param post_flair_allowed: Indicate whether the emoji may appear in post flair.
            Respects pre-existing settings if not provided.
        :param user_flair_allowed: Indicate whether the emoji may appear in user flair.
            Respects pre-existing settings if not provided.

        .. note::

            In order to retain pre-existing values for those that are not explicitly
            passed, a network request is issued. To avoid that network request,
            explicitly provide all values.

        To restrict the emoji ``"emoji"`` in r/test to mod use only, try:

        .. code-block:: python

            reddit.subreddit("test").emoji["emoji"].update(mod_flair_only=True)

        r/   c              3  ó$   K  — | ]  }|d u –— Œ
 y ­w©N© )Ú.0Úvalues     r   ú	<genexpr>zEmoji.update.<locals>.<genexpr>y   s   è ø€ Ò; ˆu˜Œ}Ñ;ùs   ‚z'At least one attribute must be providedr   NÚemoji_update©r   ©Údata)ÚlocalsÚallÚvaluesÚ	TypeErrorr   ÚitemsÚgetattrr   r+   r   r,   ÚpostÚsetattr)r   r0   r1   r2   Úlocals_referenceÚ	attributeÚmappingr'   r=   r8   r.   s              r   r%   zEmoji.updateS   sþ   € ô: "›8Ððö
àð Ð'¨	Ñ2Ñ2ð
ˆð 
ô Ñ;¨'¯.©.Ó*:Ô;Ô;Ø;ˆCÜ˜C“.Ð à˜Ÿ	™	Ð"ˆØ '§¡£ò 	$ÑˆI�uØˆ}Ü  iÓ0�Ø#ˆD�ŠOð	$ô �~Ñ&×-Ñ-¸¿¹Ð-ÓGˆØ�‰×Ñ˜# DÐÔ)Ø $§
¡
£ò 	,ÑˆI�uÜ�D˜) UÕ+ñ	,ùò'
s   �C*)r   zstr | EmojiÚreturnÚbool)rI   Úintr5   )
r!   zpraw.Redditr   úmodels.Subredditr   r   r   zdict[str, Any] | NonerI   ÚNone)rI   rM   )r0   úbool | Noner1   rN   r2   rN   rI   rM   )r   Ú
__module__Ú__qualname__Ú__doc__Ú	STR_FIELDr   r   r    r&   r-   r%   Ú__classcell__)r   s   @r   r   r      s–   ø„ ñð  €Iõ%óVð (,ð
.àð
.ð $ð
.ð ð	
.ð
 %ð
.ð 
õ
.õ#ó!ð  '+Ø*.Ø*.ñ2,ð $ð2,ð (ð	2,ð
 (ð2,ð 
÷2,r   r   c                  óP   — e Zd ZdZdd„Zd	d„Zd
d„Zddddœ	 	 	 	 	 	 	 	 	 	 	 dd„Zy)ÚSubredditEmojiz?Provides a set of functions to a :class:`.Subreddit` for emoji.c                óD   — t        | j                  | j                  |«      S )a;  Lazily return the :class:`.Emoji` for the subreddit named ``name``.

        :param name: The name of the emoji.

        This method is to be used to fetch a specific emoji url, like so:

        .. code-block:: python

            emoji = reddit.subreddit("test").emoji["emoji"]
            print(emoji)

        )r   r,   r   )r   r   s     r   Ú__getitem__zSubredditEmoji.__getitem__‹   s   € ô �T—\‘\ 4§>¡>°4Ó8Ð8r   c                ó4   — || _         |j                  | _        y)z|Initialize a :class:`.SubredditEmoji` instance.

        :param subreddit: The subreddit whose emoji are affected.

        N)r   r,   )r   r   s     r   r    zSubredditEmoji.__init__š   s   € ð #ˆŒØ ×(Ñ(ˆ�r   c              #  ó¸  K  — | j                   j                  t        d   j                  | j                  ¬«      «      }|D �cg c]7  }|j                  | j                   j                  j                  d   «      sŒ6|‘Œ9 }}t        |«      dk(  sJ ‚||d      j                  «       D ]*  \  }}t        | j                   | j                  ||¬«      –— Œ, yc c}w ­w)zþReturn a list of :class:`.Emoji` for the subreddit.

        This method is to be used to discover all emoji for a subreddit:

        .. code-block:: python

            for emoji in reddit.subreddit("test").emoji:
                print(emoji)

        Ú
emoji_listr;   r   é   r   r   N)r,   Úgetr   r+   r   Ú
startswithÚconfigÚkindsÚlenrB   r   )r   ÚresponseÚkeyÚsubreddit_keysr*   Ú
emoji_datas         r   Ú__iter__zSubredditEmoji.__iter__£   sÂ   è ø€ ð —<‘<×#Ñ#¤H¨\Ñ$:×$AÑ$AÈDÏNÉNÐ$AÓ$[Ó\ˆØ)1Öl #°S·^±^ÀDÇLÁL×DWÑDW×D]ÑD]Ð^iÑDjÕ5kš#ÐlˆÐlÜ�>Ó" aÒ'Ð'Ð'Ø&.¨~¸aÑ/@Ñ&A×&GÑ&GÓ&Iò 	TÑ"ˆJ˜
Ü˜Ÿ™ d§n¡n°jÈ
ÔSÓSñ	Tùò mùs   ‚ACÁ7CÁ;CÁ?ACNr/   c               ó
  — |j                  | j                  «      }|||||dœ}t        d   j                  | j                  ¬«      }| j                  j                  ||¬«       t        | j                  | j                  |«      S )aW  Add an emoji to this subreddit.

        :param media: The :class:`.EmojiMedia` to be uploaded as an emoji.
        :param mod_flair_only: When provided, indicate whether the emoji is restricted
            to mod use only (default: ``None``).
        :param name: The name of the emoji.
        :param post_flair_allowed: When provided, indicate whether the emoji may appear
            in post flair (default: ``None``).
        :param user_flair_allowed: When provided, indicate whether the emoji may appear
            in user flair (default: ``None``).

        :returns: The :class:`.Emoji` added.

        To add ``"emoji"`` to r/test try:

        .. code-block:: python

            from praw.models import EmojiMedia

            media = EmojiMedia("emoji.png")
            reddit.subreddit("test").emoji.add(media=media, name="emoji")

        )r0   r   r1   Ús3_keyr2   Úemoji_uploadr;   r<   )Ú_uploadr   r   r+   r,   rD   r   )	r   Úmediar0   r   r1   r2   rg   r=   r.   s	            r   ÚaddzSubredditEmoji.add´   s{   € ð@ —‘˜tŸ~™~Ó.ˆð -ØØ"4ØØ"4ñ
ˆô �~Ñ&×-Ñ-¸¿¹Ð-ÓGˆØ�‰×Ñ˜# DÐÔ)Ü�T—\‘\ 4§>¡>°4Ó8Ð8r   )r   r   rI   r   )r   rL   rI   rM   )rI   zIterator[Emoji])rj   zmodels.EmojiMediar0   rN   r   r   r1   rN   r2   rN   rI   r   )r   rO   rP   rQ   rW   r    re   rk   r6   r   r   rU   rU   ˆ   sa   „ ÙIó9ó)óTð* '+à*.Ø*.ñ+9ð !ð+9ð $ð	+9ð
 ð+9ð (ð+9ð (ð+9ð 
ô+9r   rU   )rQ   Ú
__future__r   Útypingr   r   Ú
praw.constr   Úpraw.exceptionsr   Úpraw.models.reddit.baser   Úcollections.abcr	   Úprawr
   r   rU   r6   r   r   ú<module>rs      s>   ðÙ å "ç %å Ý +Ý .áÝ(ãÝôs,ˆJô s,÷lW9ò W9r   