
    {i_!                        S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  SSK
Jr  SSKJr  S	S
KJr  \(       a  SSKr " S S\5      r " S S5      rg)zProvide the Emoji class.    )annotations)Path)TYPE_CHECKINGAny   )API_PATH)ClientException)_deprecate_args   )
RedditBaseNc                     ^  \ rS rSrSrSrSU 4S jjrSS jr S       SU 4S jjjrU 4S jr	S	 r
\" S
SS5      SSSS.     SS jj5       rSrU =r$ )Emoji   a  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                
  > [        U[        5      (       a  U[        U 5      :H  $ [        XR                  5      (       a7  [        U 5      [        U5      :H  =(       a    UR                  U R                  :H  $ [        TU ]  U5      $ )z5Return whether the other instance equals the current.)
isinstancestr	__class__	subredditsuper__eq__)selfotherr   s     R/home/james-whalen/.local/lib/python3.13/site-packages/praw/models/reddit/emoji.pyr   Emoji.__eq__$   sb    eS!!CI%%e^^,,t9E
*Pu$../PPw~e$$    c                    [        U R                  R                  5      [        [        U 5      5      -  [        U R                  5      -  $ )z(Return the hash of the current instance.)hashr   __name__r   r   )r   s    r   __hash__Emoji.__hash__,   s2    DNN++,tCI>dnnAUUUr   Nc                8   > X0l         X l        [        TU ]  XS9  g)z'Initialize an :class:`.Emoji` instance._dataN)r   r   r   __init__)r   redditr   r   r$   r   s        r   r%   Emoji.__init__0   s     	"-r   c                *  > U R                   R                   HR  nUR                  U R                  :X  d  M  U R                  R	                  UR                  5        [
        TU ]  5           g    SU R                    SU R                   3n[        U5      e)Nzr/z does not have the emoji )r   emojir   __dict__updater   _fetchr	   )r   r)   msgr   s      r   r,   Emoji._fetch<   ss    ^^))EzzTYY&$$U^^4 	 *
 4>>"";DII;Gc""r   c                    [         S   R                  U R                  U R                  S9nU R                  R                  U5        g)zDelete 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   r4   Emoji.deleteE   s?     ~&--yyDNN . 
 	C r   mod_flair_onlypost_flair_alloweduser_flair_allowedr7   r8   r9   c                  [        5       nS Vs0 s H  nXTU   _M
     nn[        S UR                  5        5       5      (       a  Sn[        U5      eSU R                  0nUR                  5        H  u  pYU	c  [        X5      n	XU'   M     [        S   R                  U R                  S9n
U R                  R                  XS9  UR                  5        H  u  pY[        XU	5        M     gs  snf )	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  (   #    U  H  oS L v   M
     g 7fN ).0values     r   	<genexpr>Emoji.update.<locals>.<genexpr>{   s     ;*:}*:s   z'At least one attribute must be providedr   Nemoji_updater   data)localsallvalues	TypeErrorr   itemsgetattrr   r2   r   r3   postsetattr)r   r7   r8   r9   locals_reference	attributemappingr-   rF   r@   r5   s              r   r+   Emoji.updateT   s    < "8
	 	22 	 
 ;'..*:;;;;CC. 		" 'I}0#O !0 ~&---G#) $

IDU+ !-'
s   C*)r   r   )r   zstr | Emojireturnbool)rS   intr=   )r&   zpraw.Redditr   praw.models.Subredditr   r   r$   zdict[str, Any] | None)r7   bool | Noner8   rW   r9   rW   )r   
__module____qualname____firstlineno____doc__	STR_FIELDr   r    r%   r,   r4   r
   r+   __static_attributes____classcell__)r   s   @r   r   r      s      I%V (,
.
. )
. 	
.
 %
. 
.#! %';=QR '+*.*.2, $2, (	2,
 (2, S2,r   r   c                  b    \ rS rSrSrS
S jrSS jrSS jrSSSS.           SS jjrS	r	g)SubredditEmoji   z?Provides a set of functions to a :class:`.Subreddit` for emoji.c                D    [        U R                  U R                  U5      $ )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   r3   r   )r   r   s     r   __getitem__SubredditEmoji.__getitem__   s     T\\4>>488r   c                2    Xl         UR                  U l        g)zlInitialize a :class:`.SubredditEmoji` instance.

:param subreddit: The subreddit whose emoji are affected.

N)r   r3   )r   r   s     r   r%   SubredditEmoji.__init__   s     # ((r   c              #    #    U R                   R                  [        S   R                  U R                  S95      nU Vs/ s H>  nUR                  U R                   R                  R                  S   5      (       d  M<  UPM@     nn[        U5      S:X  d   eXS      R                  5        H&  u  pE[        U R                   U R                  XES9v   M(     gs  snf 7f)zReturn 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_listrD   r   r   r   r#   N)r3   getr   r2   r   
startswithconfigkindslenrK   r   )r   responsekeysubreddit_keysr1   
emoji_datas         r   __iter__SubredditEmoji.__iter__   s      <<##\"))DNN)C

  
~~dll1177DE  	 

 >"a'''&.a/@&A&G&G&I"JdnnjSS 'J
s   >C ;C?CACNr:   c                  [        U5      nUR                  SS.nUR                  5       R                  S5      (       a  SUS'   [        S   R                  U R                  S9nU R                  R                  XS9S	   n	U	S
    V
s0 s H  oS   U
S   _M     nn
SU	S    3nUR                  S5       nU R                  R                  R                  R                  R                  XSU0S9nSSS5        WR                  5         UUUUS   US.n[        S   R                  U R                  S9nU R                  R                  XS9  [        U R                  U R                  U5      $ s  sn
f ! , (       d  f       N= f)a  Add an emoji to this subreddit.

:param image_path: A path to a jpeg or png image.
: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

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

z
image/jpeg)filepathmimetypez.pngz	image/pngrv   emoji_leaserD   rE   s3UploadLeasefieldsr   r@   zhttps:actionrbfile)rF   filesNro   )r7   r   r8   s3_keyr9   emoji_upload)r   r   lowerendswithr   r2   r   r3   rM   open_core
_requestor_httpraise_for_statusr   )r   
image_pathr7   r   r8   r9   r|   rF   r5   upload_leaseitemupload_data
upload_urlimagern   s                  r   addSubredditEmoji.add   s   : J		$
 &&v..*D}%,,t~~,F ||(((8I?KH?UV?UtF|T']2?UVl8456
YYt_||))44::??VUO @ H  	!!# -"4!%("4
 ~&---G#)T\\4>>488% W _s   E,4;E11
E?)r3   r   )r   r   rS   r   )r   rV   )rS   zlist[Emoji])r   r   r7   rW   r   r   r8   rW   r9   rW   rS   r   )
r   rX   rY   rZ   r[   rc   r%   rr   r   r]   r>   r   r   r`   r`      sf    I9)T6 '+*.*.:9 :9 $	:9
 :9 (:9 (:9 
:9 :9r   r`   )r[   
__future__r   pathlibr   typingr   r   constr   
exceptionsr	   utilr
   baser   prawr   r`   r>   r   r   <module>r      s>     "  %  ) # v,J v,rl9 l9r   