Ë
    Fü´jî  ã                  ó¦   — d Z ddlmZ ddlmZmZmZ ddl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 Removal Reason class.é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚSupportsIndex)ÚAPI_PATH)ÚClientException)Ú
RedditBase)Úcachedproperty)ÚIteratorN)Úmodelsc                  ót   ‡ — e Zd ZdZdZdd„Zdd„Z	 	 d	 	 	 	 	 	 	 	 	 dˆ fd„Zdˆ fd„Zdd„Z	ddd	œdd
„Z
ˆ xZS )ÚRemovalReasona¡  An individual Removal Reason object.

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

    =========== ==================================
    Attribute   Description
    =========== ==================================
    ``id``      The ID of the removal reason.
    ``message`` The message of the removal reason.
    ``title``   The title of the removal reason.
    =========== ==================================

    Úidc                óœ   — t        |t        «      r|t        | «      k(  S t        || j                  «      xr t        | «      t        |«      k(  S )z5Return whether the other instance equals the current.)Ú
isinstanceÚstrÚ	__class__)ÚselfÚothers     ú`/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/removal_reasons.pyÚ__eq__zRemovalReason.__eq__$   s>   € ä�eœSÔ!ØœC ›IÑ%Ð%Ü˜% §¡Ó0ÒL´S¸³YÄ#ÀeÃ*Ñ5LÐLó    c                ój   — t        | j                  j                  «      t        t        | «      «      z  S )z(Return the hash of the current instance.)Úhashr   Ú__name__r   ©r   s    r   Ú__hash__zRemovalReason.__hash__*   s$   € ä�D—N‘N×+Ñ+Ó,¬t´C¸³I«Ñ>Ð>r   Nc                óŽ   •— ||fj                  d«      dk7  rd}t        |«      ‚|r|| _        || _        t        ‰| �  ||¬«       y)zàInitialize a :class:`.RemovalReason` instance.

        :param reddit: An instance of :class:`.Reddit`.
        :param subreddit: An instance of :class:`.Subreddit`.
        :param id: The ID of the removal reason.

        Né   z%Either id or _data needs to be given.©Ú_data)ÚcountÚ
ValueErrorr   Ú	subredditÚsuperÚ__init__)r   Úredditr$   r   r!   Úmsgr   s         €r   r&   zRemovalReason.__init__.   sN   ø€ ð �ˆ;×Ñ˜TÓ" aÒ'Ø9ˆCÜ˜S“/Ð!áØˆDŒGØ"ˆŒÜ‰Ñ˜ uÐÕ-r   c                ó8  •— | j                   j                  j                  D ]P  }|j                  | j                  k(  sŒ| j                  j                  |j                  «       t        ‰| �  «         y  d| j                   › d| j                  › �}t        |«      ‚)Nz
Subreddit z" does not have the removal reason )	r$   ÚmodÚremoval_reasonsr   Ú__dict__Úupdater%   Ú_fetchr   )r   Úremoval_reasonr(   r   s      €r   r.   zRemovalReason._fetchE   s‚   ø€ Ø"Ÿn™n×0Ñ0×@Ñ@ò 	ˆNØ× Ñ  D§G¡GÓ+Ø—‘×$Ñ$ ^×%<Ñ%<Ô=Ü‘‘Ô Ùð		ð
 ˜4Ÿ>™>Ð*Ð*LÈTÏWÉWÈIÐVˆÜ˜cÓ"Ð"r   c                ó–   — t         d   j                  | j                  | j                  ¬«      }| j                  j                  |«       y)zâDelete a removal reason from this subreddit.

        To delete ``"141vv5c16py7d"`` from r/test try:

        .. code-block:: python

            reddit.subreddit("test").mod.removal_reasons["141vv5c16py7d"].delete()

        r/   ©r   r$   N)r   Úformatr   r$   Ú_redditÚdelete)r   Úurls     r   r4   zRemovalReason.deleteN   s9   € ô Ð'Ñ(×/Ñ/°4·7±7ÀdÇnÁnÐ/ÓUˆØ�‰×Ñ˜CÕ r   ©ÚmessageÚtitlec          	     ó  — t         d   j                  | j                  | j                  ¬«      }||dœj	                  «       D ��ci c]  \  }}||€t        | |«      n|“Œ }}}| j                  j                  ||¬«       yc c}}w )a÷  Update the removal reason from this subreddit.

        .. note::

            Existing values will be used for any unspecified arguments.

        :param message: The removal reason's new message.
        :param title: The removal reason's new title.

        To update ``"141vv5c16py7d"`` from r/test try:

        .. code-block:: python

            reddit.subreddit("test").mod.removal_reasons["141vv5c16py7d"].update(
                title="New title", message="New message"
            )

        r/   r1   r6   N©Údata)r   r2   r   r$   ÚitemsÚgetattrr3   Úput)r   r7   r8   r5   ÚnameÚvaluer;   s          r   r-   zRemovalReason.update[   sˆ   € ô& Ð'Ñ(×/Ñ/°4·7±7ÀdÇnÁnÐ/ÓUˆð ,3¸UÑC×IÑIÓK÷
á��eð ¨¨”'˜$ Ô%¸EÑAð
ˆñ 
ð 	�‰×Ñ˜ 4ÐÕ(ùó	
s   ÁB)r   zstr | RemovalReasonÚreturnÚbool)rA   Úint)NN)
r'   zpraw.Redditr$   úmodels.Subredditr   ú
str | Noner!   zdict[str, Any] | NonerA   ÚNone)rA   rF   )r7   rE   r8   rE   rA   rF   )r   Ú
__module__Ú__qualname__Ú__doc__Ú	STR_FIELDr   r   r&   r.   r4   r-   Ú__classcell__)r   s   @r   r   r      sr   ø„ ñð €IóMó?ð Ø'+ð.àð.ð $ð.ð ð	.ð
 %ð.ð 
õ.õ.#ó!ð /3È÷ )ñ )r   r   c                  óB   — e Zd ZdZedd„«       Zd	d„Zd
d„Zdd„Zdd„Z	y)ÚSubredditRemovalReasonszFProvide a set of functions to a :class:`.Subreddit`'s removal reasons.c           	     óö   — | j                   j                  t        d   j                  | j                  ¬«      «      }|d   D �cg c]*  }t        | j                   | j                  |d   |   ¬«      ‘Œ, c}S c c}w )zrGet a list of Removal Reason objects.

        :returns: A list of instances of :class:`.RemovalReason`.

        Úremoval_reasons_list©r$   Úorderr;   r    )r3   Úgetr   r2   r$   r   )r   ÚresponseÚ	reason_ids      r   Ú_removal_reason_listz,SubredditRemovalReasons._removal_reason_listy   su   € ð —<‘<×#Ñ#¤HÐ-CÑ$D×$KÑ$KÐVZ×VdÑVdÐ$KÓ$eÓfˆð & gÑ.ö
àô ˜$Ÿ,™,¨¯©¸hÀvÑ>NÈyÑ>YÖZò
ð 	
ùò 
s   Á/A6c                ó‚   — t        |t        «      s| j                  |   S t        | j                  | j
                  |«      S )ac  Return the Removal Reason with the ID/number/slice ``reason_id``.

        :param reason_id: The ID or index of the removal reason

        .. note::

            Removal reasons fetched using a specific rule name are lazily loaded, so you
            might have to access an attribute to get all the expected attributes.

        This method is to be used to fetch a specific removal reason, like so:

        .. code-block:: python

            reason_id = "141vv5c16py7d"
            reason = reddit.subreddit("test").mod.removal_reasons[reason_id]
            print(reason)

        You can also use indices to get a numbered removal reason. Since Python uses
        0-indexing, the first removal reason is index 0, and so on.

        .. note::

            Both negative indices and slices can be used to interact with the removal
            reasons.

        :raises: :py:class:`IndexError` if a removal reason of a specific number does
            not exist.

        For example, to get the second removal reason of r/test:

        .. code-block:: python

            reason = reddit.subreddit("test").mod.removal_reasons[1]

        To get the last three removal reasons in a subreddit:

        .. code-block:: python

            reasons = reddit.subreddit("test").mod.removal_reasons[-3:]
            for reason in reasons:
                print(reason)

        )r   r   rU   r   r3   r$   )r   rT   s     r   Ú__getitem__z#SubredditRemovalReasons.__getitem__†   s7   € ôX ˜)¤SÔ)Ø×,Ñ,¨YÑ7Ð7Ü˜TŸ\™\¨4¯>©>¸9ÓEÐEr   c                ó4   — || _         |j                  | _        y)z�Initialize a :class:`.SubredditRemovalReasons` instance.

        :param subreddit: The subreddit whose removal reasons to work with.

        N)r$   r3   )r   r$   s     r   r&   z SubredditRemovalReasons.__init__¶   s   € ð #ˆŒØ ×(Ñ(ˆ�r   c                ó,   — t        | j                  «      S )a"  Return a list of Removal Reasons for the subreddit.

        This method is used to discover all removal reasons for a subreddit:

        .. code-block:: python

            for removal_reason in reddit.subreddit("test").mod.removal_reasons:
                print(removal_reason)

        )ÚiterrU   r   s    r   Ú__iter__z SubredditRemovalReasons.__iter__¿   s   € ô �D×-Ñ-Ó.Ð.r   c               óÎ   — ||dœ}t         d   j                  | j                  ¬«      }| j                  j	                  ||¬«      }t        | j                  | j                  |«      S )aÝ  Add a removal reason to this subreddit.

        :param message: The message associated with the removal reason.
        :param title: The title of the removal reason.

        :returns: The :class:`.RemovalReason` added.

        The message will be prepended with ``Hi u/username,`` automatically.

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

        .. code-block:: python

            reddit.subreddit("test").mod.removal_reasons.add(title="Test", message="Foobar")

        r6   rO   rP   r:   )r   r2   r$   r3   Úpostr   )r   r7   r8   r;   r5   rT   s         r   ÚaddzSubredditRemovalReasons.addÌ   s[   € ð" #¨UÑ3ˆÜÐ-Ñ.×5Ñ5ÀÇÁÐ5ÓOˆØ—L‘L×%Ñ% c°Ð%Ó5ˆ	Ü˜TŸ\™\¨4¯>©>¸9ÓEÐEr   N)rA   zlist[RemovalReason])rT   r   rA   r   )r$   rD   rA   rF   )rA   zIterator[RemovalReason])r7   r   r8   r   rA   r   )
r   rG   rH   rI   r
   rU   rW   r&   r[   r^   © r   r   rM   rM   v   s.   „ ÙPàò

ó ð

ó.Fó`)ó/ôFr   rM   )rI   Ú
__future__r   Útypingr   r   r   Ú
praw.constr   Úpraw.exceptionsr   Úpraw.models.reddit.baser	   Ú	praw.utilr
   Úcollections.abcr   Úprawr   r   rM   r_   r   r   ú<module>rh      sF   ðÙ 'å "ç 4Ñ 4å Ý +Ý .Ý $áÝ(ãÝô`)�Jô `)÷FjFò jFr   