Ë
    Fü´jD$  ã                  óÆ   — d Z ddlmZ ddl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 dd
lmZ ddlmZmZ ddlmZ er
ddlZddlmZ  G d„ deee«      Zy)zProvide the Multireddit class.é    )ÚannotationsN)Údumps)ÚTYPE_CHECKINGÚAnyÚcast)ÚAPI_PATH)ÚSubredditListingMixin)Ú
RedditBase)ÚCreatedMixin)ÚRedditor)Ú	SubredditÚSubredditStream)Úcachedproperty)Úmodelsc                  óÔ   ‡ — e Zd ZdZ ej
                  dej                  «      ZdZdZ	e
dd„«       Zedd„«       Zdˆ fd„Zdˆ fd„Zdd	„Zdd
„Zddœdd„Zdd„Zdd„Z	 	 	 	 dd„Zˆ xZS )ÚMultiredditaÍ  A class for users' multireddits.

    This is referred to as a "Custom Feed" on the Reddit UI.

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

    ==================== ==============================================================
    Attribute            Description
    ==================== ==============================================================
    ``can_edit``         A ``bool`` representing whether or not the authenticated user
                         may edit the multireddit.
    ``copied_from``      The multireddit that the multireddit was copied from, if it
                         exists, otherwise ``None``.
    ``created_utc``      When the multireddit was created, in `Unix Time`_.
    ``description_html`` The description of the multireddit, as HTML.
    ``description_md``   The description of the multireddit, as Markdown.
    ``display_name``     The display name of the multireddit.
    ``name``             The name of the multireddit.
    ``over_18``          A ``bool`` representing whether or not the multireddit is
                         restricted for users over 18.
    ``subreddits``       A list of :class:`.Subreddit`\ s that make up the multireddit.
    ``visibility``       The visibility of the multireddit, either ``"private"``,
                         ``"public"``, or ``"hidden"``.
    ==================== ==============================================================

    .. _unix time: https://en.wikipedia.org/wiki/Unix_time

    z[\W_]+é   Úpathc                ó  — t         j                  j                  d| «      j                  d«      j	                  «       } t        | «      t         j                  kD  r.| dt         j                   } | j                  d«      }|dkD  r| d| } | xs dS )zŠReturn a slug version of the title.

        :param title: The title to make a slug of.

        Adapted from Reddit's utils.py.

        Ú_Nr   )r   Ú
RE_INVALIDÚsubÚstripÚlowerÚlenÚSLUG_CUTOFF_LENGTHÚrfind)ÚtitleÚ	last_words     úV/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/multi.pyÚsluggifyzMultireddit.sluggify8   s€   € ô ×&Ñ&×*Ñ*¨3°Ó6×<Ñ<¸SÓA×GÑGÓIˆÜˆu‹:œ×6Ñ6Ò6ØÐ:œK×:Ñ:Ð;ˆEØŸ™ CÓ(ˆIØ˜1Š}Ø˜j˜yÐ)�ØŠ|˜Ðó    c                ó,   — t        t        d| «      «      S )a¥  Provide an instance of :class:`.SubredditStream`.

        Streams can be used to indefinitely retrieve new comments made to a multireddit,
        like:

        .. code-block:: python

            for comment in reddit.multireddit(redditor="spez", name="fun").stream.comments():
                print(comment)

        Additionally, new submissions can be retrieved via the stream. In the following
        example all new submissions to the multireddit are fetched:

        .. code-block:: python

            for submission in reddit.multireddit(
                redditor="bboe", name="games"
            ).stream.submissions():
                print(submission)

        úmodels.Subreddit)r   r   ©Úselfs    r    ÚstreamzMultireddit.streamI   s   € ô. œtÐ$6¸Ó=Ó>Ð>r"   c                óÂ  •— d| _         t        ‰| �	  ||¬«       | j                   €J ‚t        || j                   j	                  dd«      d   «      | _        t        d   j                  | j                  | j
                  ¬«      | _	        d| j                  dd › �| _         d	| j                  v r-| j                  D �cg c]  }t        ||d
   «      ‘Œ c}| _        yyc c}w )z,Initialize a :class:`.Multireddit` instance.N©Ú_dataú/é   é   Úmultireddit©ÚmultiÚuseréÿÿÿÿÚ
subredditsÚname)r   ÚsuperÚ__init__r   ÚsplitÚ_authorr   Úformatr4   Ú_pathÚ__dict__r3   r   )r&   Úredditr*   ÚxÚ	__class__s       €r    r6   zMultireddit.__init__b   sÀ   ø€ à $ˆŒ	Ü‰Ñ˜ uÐÔ-Ø�y‰yÐ$Ð$Ð$Ü ¨¯	©	¯©¸¸QÓ(?ÀÑ(BÓCˆŒÜ˜mÑ,×3Ñ3¸$¿)¹)È$Ï,É,Ð3ÓWˆŒ
Ø˜Ÿ
™
 3 B˜Ð(Ð)ˆŒ	Ø˜4Ÿ=™=Ñ(ØEIÇ_Á_ÖUÀœy¨°°6±Õ;ÒUˆD�Oð )ùÚUs   Â<Cc                óÐ   •— | j                  «       }|d   } t        | «      | j                  |¬«      }| j                  j	                  |j                  «       t
        ‰| �  «        y )NÚdatar)   )Ú_fetch_dataÚtypeÚ_redditr;   Úupdater5   Ú_fetch)r&   r@   Úotherr>   s      €r    rE   zMultireddit._fetchm   sP   ø€ Ø×ÑÓ!ˆØ�F‰|ˆØ”�T“
˜4Ÿ<™<¨tÔ4ˆØ�‰×Ñ˜UŸ^™^Ô,Ü‰‰Õr"   c                óN   — d| j                   | j                  j                   dœd fS )NÚmultireddit_apir/   )r4   r8   r%   s    r    Ú_fetch_infozMultireddit._fetch_infot   s(   € àØ—i‘i¨¯©×):Ñ):Ñ;Øð
ð 	
r"   c           
     óê   — t         d   j                  | j                  || j                  ¬«      }| j                  j                  |dt        dt        |«      i«      i¬«       | j                  d«       y)aM  Add a subreddit to this multireddit.

        :param subreddit: The subreddit to add to this multi.

        For example, to add r/test to multireddit ``bboe/test``:

        .. code-block:: python

            subreddit = reddit.subreddit("test")
            reddit.multireddit(redditor="bboe", name="test").add(subreddit)

        Úmultireddit_update©r0   Ú	subredditr1   Úmodelr4   ©r@   r3   N)	r   r9   r4   r8   rC   Úputr   ÚstrÚ_reset_attributes©r&   rM   Úurls      r    ÚaddzMultireddit.add{   sd   € ô Ð+Ñ,×3Ñ3¸$¿)¹)ÈyÐ_c×_kÑ_kÐ3ÓlˆØ�‰×Ñ˜ G¬U°F¼CÀ	»NÐ3KÓ-LÐ#MÐÔNØ×Ñ˜|Õ,r"   N)Údisplay_namec               ó6  — |r| j                  |«      }n| j                  }| j                  }|| j                  t        d   j                  || j                  j                  j                  «       ¬«      dœ}| j                  j                  t        d   |¬«      S )a  Copy this multireddit and return the new multireddit.

        :param display_name: The display name for the copied multireddit. Reddit will
            generate the ``name`` field from this display name. When not provided the
            copy will use the same display name and name as this multireddit.

        To copy the multireddit ``bboe/test`` with a name of ``"testing"``:

        .. code-block:: python

            reddit.multireddit(redditor="bboe", name="test").copy(display_name="testing")

        r.   r/   )rV   ÚfromÚtoÚmultireddit_copyrO   )
r!   rV   r4   r   r   r9   rC   r1   ÚmeÚpost)r&   rV   r4   r@   s       r    ÚcopyzMultireddit.copyŒ   s‡   € ñ Ø—=‘= Ó.‰Dà×,Ñ,ˆLØ—9‘9ˆDà(Ø—I‘IÜ˜=Ñ)×0Ñ0°tÀ$Ç,Á,×BSÑBS×BVÑBVÓBXÐ0ÓYñ
ˆð
 �|‰|× Ñ ¤Ð*<Ñ!=ÀDÐ ÓIÐIr"   c                óª   — t         d   j                  | j                  | j                  j                  ¬«      }| j                  j                  |«       y)zÄDelete this multireddit.

        For example, to delete multireddit ``bboe/test``:

        .. code-block:: python

            reddit.multireddit(redditor="bboe", name="test").delete()

        rH   r/   N)r   r9   r4   r8   rC   Údelete)r&   r   s     r    r_   zMultireddit.delete¦   s?   € ô Ð)Ñ*×1Ñ1¸¿	¹	ÈÏÉ×HYÑHYÐ1ÓZˆØ�‰×Ñ˜DÕ!r"   c           
     óê   — t         d   j                  | j                  || j                  ¬«      }| j                  j                  |dt        dt        |«      i«      i¬«       | j                  d«       y)a_  Remove a subreddit from this multireddit.

        :param subreddit: The subreddit to remove from this multi.

        For example, to remove r/test from multireddit ``bboe/test``:

        .. code-block:: python

            subreddit = reddit.subreddit("test")
            reddit.multireddit(redditor="bboe", name="test").remove(subreddit)

        rK   rL   rN   r4   rO   r3   N)	r   r9   r4   r8   rC   r_   r   rQ   rR   rS   s      r    ÚremovezMultireddit.remove³   sd   € ô Ð+Ñ,×3Ñ3¸$¿)¹)ÈyÐ_c×_kÑ_kÐ3ÓlˆØ�‰×Ñ˜C w´°v¼sÀ9»~Ð6NÓ0OÐ&PÐÔQØ×Ñ˜|Õ,r"   c                ób  — d|v r!|d   D �cg c]  }dt        |«      i‘Œ c}|d<   t        d   j                  | j                  | j                  j                  ¬«      }| j
                  j                  |dt        |«      i¬«      }| j                  j                  |j                  «       yc c}w )aš  Update this multireddit.

        Keyword arguments are passed for settings that should be updated. They can any
        of:

        :param display_name: The display name for this multireddit. Must be no longer
            than 50 characters.
        :param subreddits: Subreddits for this multireddit.
        :param description_md: Description for this multireddit, formatted in Markdown.
        :param icon_name: Can be one of: ``"art and design"``, ``"ask"``, ``"books"``,
            ``"business"``, ``"cars"``, ``"comics"``, ``"cute animals"``, ``"diy"``,
            ``"entertainment"``, ``"food and drink"``, ``"funny"``, ``"games"``,
            ``"grooming"``, ``"health"``, ``"life advice"``, ``"military"``, ``"models
            pinup"``, ``"music"``, ``"news"``, ``"philosophy"``, ``"pictures and
            gifs"``, ``"science"``, ``"shopping"``, ``"sports"``, ``"style"``,
            ``"tech"``, ``"travel"``, ``"unusual stories"``, ``"video"``, or ``None``.
        :param key_color: RGB hex color code of the form ``"#FFFFFF"``.
        :param visibility: Can be one of: ``"hidden"``, ``"private"``, or ``"public"``.
        :param weighting_scheme: Can be one of: ``"classic"`` or ``"fresh"``.

        For example, to rename multireddit ``"bboe/test"`` to ``"bboe/testing"``:

        .. code-block:: python

            reddit.multireddit(redditor="bboe", name="test").update(display_name="testing")

        r3   r4   rH   r/   rN   rO   N)
rQ   r   r9   r4   r8   rC   rP   r   r;   rD   )r&   Úupdated_settingsr   r   Únews        r    rD   zMultireddit.updateÄ   s›   € ð> Ð+Ñ+ØL\Ð]iÑLjÖ-kÀS¨v´s¸3³xÒ.@Ò-kÐ˜\Ñ*ÜÐ)Ñ*×1Ñ1¸¿	¹	ÈÏÉ×HYÑHYÐ1ÓZˆØ�l‰l×Ñ˜t¨7´EÐ:JÓ4KÐ*LÐÓMˆØ�‰×Ñ˜SŸ\™\Õ*ùò .ls   ŒB,)r   rQ   ÚreturnrQ   )re   r   )r<   zpraw.Redditr*   zdict[str, Any]re   ÚNone)re   rf   )re   z tuple[str, dict[str, str], None])rM   r$   re   rf   )rV   z
str | Nonere   zmodels.Multireddit)rc   z3str | list[str | models.Subreddit | dict[str, str]]re   rf   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚreÚcompileÚUNICODEr   r   Ú	STR_FIELDÚstaticmethodr!   r   r'   r6   rE   rI   rU   r]   r_   ra   rD   Ú__classcell__)r>   s   @r    r   r      s’   ø„ ñð: �—‘˜I r§z¡zÓ2€JØÐØ€Iàòó ðð  ò?ó ð?õ0	Võó
ó-ð" 26õ Jó4"ó-ð"#+àOð#+ð 
÷#+r"   r   )rj   Ú
__future__r   rk   Újsonr   Útypingr   r   r   Ú
praw.constr   Úpraw.models.listing.mixinsr	   Úpraw.models.reddit.baser
   Úpraw.models.reddit.mixinsr   Úpraw.models.reddit.redditorr   Úpraw.models.reddit.subredditr   r   Ú	praw.utilr   Úprawr   r   © r"   r    ú<module>r}      sH   ðÙ $å "ã 	Ý ß +Ñ +å Ý <Ý .Ý 2Ý 0ß CÝ $áÛÝôQ+Ð'¨°zõ Q+r"   