
    {i.                        S r SSKJr  SSKJrJrJrJr  SSKJ	r	  SSK
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 WikiPage class.    )annotations)TYPE_CHECKINGAny	GeneratorIterator   )API_PATH)_deprecate_args)cachedproperty   )ListingGenerator   )
RedditBase)RedditorNc                  x    \ rS rSrSrSS jrSS jrSS jrS rSS jr	\
" SS	5              SS
 j5       rSrg)WikiPageModeration   zProvides a set of moderation functions for a :class:`.WikiPage`.

For example, to add u/spez as an editor on the wikipage ``"praw_test"`` try:

.. code-block:: python

    reddit.subreddit("test").wiki["praw_test"].mod.add("spez")

c                    Xl         g)zaInitialize a :class:`.WikiPageModeration` instance.

:param wikipage: The wikipage to moderate.

Nwikipage)selfr   s     U/home/james-whalen/.local/lib/python3.13/site-packages/praw/models/reddit/wikipage.py__init__WikiPageModeration.__init__   s	     !    c                    U R                   R                  [        U5      S.n[        S   R	                  U R                   R
                  SS9nU R                   R                  R                  X2S9  g)a  Add an editor to this :class:`.WikiPage`.

:param redditor: A redditor name or :class:`.Redditor` instance.

To add u/spez as an editor on the wikipage ``"praw_test"`` try:

.. code-block:: python

    reddit.subreddit("test").wiki["praw_test"].mod.add("spez")

pageusernamewiki_page_editoradd	subredditmethoddataNr   namestrr	   formatr#   _redditpostr   redditorr&   urls       r   r!   WikiPageModeration.add%   c     **HF)*11mm--e 2 
 	""3"2r   c                    U R                   R                  [        U5      S.n[        S   R	                  U R                   R
                  SS9nU R                   R                  R                  X2S9  g)a  Remove an editor from this :class:`.WikiPage`.

:param redditor: A redditor name or :class:`.Redditor` instance.

To remove u/spez as an editor on the wikipage ``"praw_test"`` try:

.. code-block:: python

    reddit.subreddit("test").wiki["praw_test"].mod.remove("spez")

r   r    delr"   r%   Nr'   r-   s       r   removeWikiPageModeration.remove7   r1   r   c                    U R                   R                  R                  [        S   R	                  U R                   R
                  S9U R                   R                  U R                   R                  S.S9  g)a  Revert a wikipage back to a specific revision.

To revert the page ``"praw_test"`` in r/test to revision ``"1234abc"``, try

.. code-block:: python

    reddit.subreddit("test").wiki["praw_test"].revision("1234abc").mod.revert()

.. note::

    When you attempt to revert the page ``config/stylesheet``, Reddit checks to
    see if the revision being reverted to passes the CSS filter. If the check
    fails, then the revision attempt will also fail, and a
    ``prawcore.Forbidden`` exception will be raised. For example, you can't
    revert to a revision that contains a link to ``url(%%PRAW%%)`` if there is
    no image named ``PRAW`` on the current stylesheet.

    Here is an example of how to look for this type of error:

    .. code-block:: python

        from prawcore.exceptions import Forbidden

        try:
            reddit.subreddit("test").wiki["config/stylesheet"].revision("1234abc").mod.revert()
        except Forbidden as exception:
            try:
                exception.response.json()
            except ValueError:
                exception.response.text

    If the error occurs, the output will look something like

    .. code-block:: python

        {"reason": "INVALID_CSS", "message": "Forbidden", "explanation": "%(css_error)s"}

wiki_revertr#   )r   revisionr%   N)r   r+   r,   r	   r*   r#   r(   	_revisionr   s    r   revertWikiPageModeration.revertI   sa    N 	""]#**T]]5L5L*M** MM33 	# 	
r   c                    [         S   R                  U R                  R                  U R                  R                  S9nU R                  R
                  R                  U5      S   $ )z0Return the settings for this :class:`.WikiPage`.wiki_page_settingsr#   r   r&   )r	   r*   r   r#   r(   r+   get)r   r/   s     r   settingsWikiPageModeration.settingsx   sX    +,33mm--DMM4F4F 4 
 }}$$((-f55r   listed	permlevelc                   UR                  XS.5        [        S   R                  U R                  R                  U R                  R
                  S9nU R                  R                  R                  XCS9S   $ )a  Update the settings for this :class:`.WikiPage`.

:param listed: Show this page on page list.
:param permlevel: Who can edit this page? ``0`` use subreddit wiki permissions,
    ``1`` only approved wiki contributors for this page may edit (see
    :meth:`.WikiPageModeration.add`), ``2`` only mods may edit and view.
:param other_settings: Additional keyword arguments to pass.

:returns: The updated WikiPage settings.

To set the wikipage ``"praw_test"`` in r/test to mod only and disable it from
showing in the page list, try:

.. code-block:: python

    reddit.subreddit("test").wiki["praw_test"].mod.update(listed=False, permlevel=2)

)rD   rE   r?   r@   r%   r&   )updater	   r*   r   r#   r(   r+   r,   )r   rD   rE   other_settingsr/   s        r   rG   WikiPageModeration.update   sn    , 	HI+,33mm--DMM4F4F 4 
 }}$$))#)CFKKr   r   N)r   WikiPage)r.   zpraw.models.Redditor)returndict[str, Any])rD   boolrE   intrH   r   rK   rL   )__name__
__module____qualname____firstlineno____doc__r   r!   r4   r<   rB   r
   rG   __static_attributes__ r   r   r   r      sb    !3$3$-
^6 X{+LL*-LADL	L ,Lr   r   c                    ^  \ rS rSrSr\R                  r\        SS j5       r\	SS j5       r
  S         SU 4S jjjrSS jrSS jrU 4S	 jrS
 rSS jr\" SS5      SS.SS jj5       rSS jr    SS jrSrU =r$ )rJ      a  An individual :class:`.WikiPage` object.

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

================= =================================================================
Attribute         Description
================= =================================================================
``content_html``  The contents of the wiki page, as HTML.
``content_md``    The contents of the wiki page, as Markdown.
``may_revise``    A ``bool`` representing whether or not the authenticated user may
                  edit the wiki page.
``name``          The name of the wiki page.
``revision_by``   The :class:`.Redditor` who authored this revision of the wiki
                  page.
``revision_date`` The time of this revision, in `Unix Time`_.
``subreddit``     The :class:`.Subreddit` this wiki page belongs to.
================= =================================================================

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

c              #     #    [        UR                  U40 U D6 HJ  nUS   b  [        UR                  US   S   S9US'   [        UR                  XS   US   5      US'   Uv   ML     g 7f)Nauthorr&   _datar   id)r   r+   r   rJ   )generator_kwargsr#   r/   r9   s       r   _revision_generatorWikiPage._revision_generator   s      )):):CTCSTH!-%-%%Xh-?-G&"  (!!9v.> HV N Us   A'A)c                    [        U 5      $ )zProvide an instance of :class:`.WikiPageModeration`.

For example, to add u/spez as an editor on the wikipage ``"praw_test"`` try:

.. code-block:: python

    reddit.subreddit("test").wiki["praw_test"].mod.add("spez")

)r   r;   s    r   modWikiPage.mod   s     "$''r   Nc                F   > X0l         X@l        X l        [        TU ]  XSS9  g)zInitialize a :class:`.WikiPage` instance.

:param revision: A specific revision ID to fetch. By default, fetches the most
    recent revision.

F)r[   
_str_fieldN)r(   r:   r#   superr   )r   redditr#   r(   r9   r[   	__class__s         r   r   WikiPage.__init__   s&     	!"?r   c                l    U R                   R                   SU R                  < SU R                  < S3$ )z?Return an object initialization representation of the instance.z(subreddit=z, name=))rg   rO   r#   r(   r;   s    r   __repr__WikiPage.__repr__   s:     ~~&&'{4>>2D EYYM$	
r   c                8    U R                    SU R                   3$ )z/Return a string representation of the instance./)r#   r(   r;   s    r   __str__WikiPage.__str__   s    ..!499+..r   c                   > U R                  5       nUS   nUS   b  [        U R                  US   S   S9US'   U R                  R	                  U5        [
        TU ]  5         g )Nr&   revision_byrZ   )_fetch_datar   r+   __dict__rG   re   _fetch)r   r&   rg   s     r   ru   WikiPage._fetch   se    !F|*"*D$7$?#D 	T"r   c                z    SU R                   U R                  S.U R                  (       a  SU R                  04$ S 4$ )N	wiki_pager@   v)r#   r(   r:   r;   s    r   _fetch_infoWikiPage._fetch_info   s@    ..$))<%)^^S$..!
 	
 :>
 	
r   c                    [        U R                  [        S   R                  U R                  U R
                  S940 UD6$ )a  Return a :class:`.ListingGenerator` for discussions of a wiki page.

Discussions are site-wide links to a wiki page.

Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.

To view the titles of discussions of the page ``"praw_test"`` in r/test, try:

.. code-block:: python

    for submission in reddit.subreddit("test").wiki["praw_test"].discussions():
        print(submission.title)

wiki_discussionsr@   )r   r+   r	   r*   r#   r(   )r   r]   s     r   discussionsWikiPage.discussions  sH       LL'(//..tyy 0 

 
 	
r   contentreason)r   c                   UR                  XR                  US.5        U R                  R                  [        S   R                  U R                  S9US9  g)a  Edit this wiki page's contents.

:param content: The updated Markdown content of the page.
:param reason: The reason for the revision.
:param other_settings: Additional keyword arguments to pass.

For example, to replace the first wiki page of r/test with the phrase ``"test
wiki page"``:

.. code-block:: python

    page = next(iter(reddit.subreddit("test").wiki))
    page.edit(content="test wiki page")

)r   r   r   	wiki_editr8   r%   N)rG   r(   r+   r,   r	   r*   r#   )r   r   r   rH   s       r   editWikiPage.edit  sO    " 	'99PVWX[!((4>>(B 	 	
r   c                n    [        U R                  R                  U R                  U R                  U5      $ )zReturn a specific version of this page by revision ID.

To view revision ``"1234abc"`` of ``"praw_test"`` in r/test:

.. code-block:: python

    page = reddit.subreddit("test").wiki["praw_test"].revision("1234abc")

)rJ   r#   r+   r(   )r   r9   s     r   r9   WikiPage.revision2  s'     ..		8TTr   c                    [         S   R                  U R                  U R                  S9nU R	                  XR                  US9$ )a  Return a :class:`.ListingGenerator` for page revisions.

Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.

To view the wiki revisions for ``"praw_test"`` in r/test try:

.. code-block:: python

    for item in reddit.subreddit("test").wiki["praw_test"].revisions():
        print(item)

To get :class:`.WikiPage` objects for each revision:

.. code-block:: python

    for item in reddit.subreddit("test").wiki["praw_test"].revisions():
        print(item["page"])

wiki_page_revisionsr@   )r]   r#   r/   )r	   r*   r#   r(   r^   )r   r]   r/   s      r   	revisionsWikiPage.revisions>  sO    . ,-44nn499 5 
 ''-S ( 
 	
r   )r:   r(   r#   )r]   rL   r#   praw.models.Subredditr/   r)   rK   zOGenerator[dict[str, Redditor | WikiPage | str | int | bool | None], None, None])rK   r   )NN)
rf   zpraw.Redditr#   r   r(   r)   r9   
str | Noner[   zdict[str, Any] | None)rK   r)   )r]   r   rK   z Iterator[praw.models.Submission])r   r)   r   r   rH   r   )r9   r)   rK   rJ   )r]   zstr | int | dict[str, str]rK   zGenerator[WikiPage, None, None])rO   rP   rQ   rR   rS   r   __hash__staticmethodr^   r   ra   r   rk   ro   ru   rz   r~   r
   r   r9   r   rT   __classcell__)rg   s   @r   rJ   rJ      s   , ""H( ) 	

 $ 
( 
("  $'+@@ )@ 	@
 @ %@ @&
/

0 Y)9= 
 *
*
U
"<
	(
 
r   rJ   )rS   
__future__r   typingr   r   r   r   constr	   utilr
   
util.cacher   listing.generatorr   baser   r.   r   praw.modelsprawr   rJ   rU   r   r   <module>r      sF    ! " : :  # ( 0  GL GLT~
z ~
r   