Ë
    Fü´j�  ã                  ót   — d Z ddlmZ ddlmZ ddlmZmZ ddlmZm	Z	 erddl
Z
 G d„ d«      Z G d	„ d
«      Zy)z Provide the PRAWBase superclass.é    )Úannotations)Údeepcopy)ÚdatetimeÚtimezone)ÚTYPE_CHECKINGÚAnyNc                  ó   — e Zd ZdZdd„Zy)ÚDynamicAttributesaè  Mixin for objects whose attributes are populated from Reddit response data.

    Reddit adds and removes fields without notice, so PRAW sets these attributes
    dynamically rather than declaring them. Defining ``__getattr__`` (typed to return
    ``Any``) tells type checkers that attribute access on such objects is permitted,
    which is required for downstream projects to type check against PRAW's ``py.typed``
    marker. :class:`.RedditBase` provides equivalent behavior (with lazy fetching) for
    the objects it backs; this mixin covers the :class:`.PRAWBase` data classes that do
    not inherit it.

    It does not change runtime behavior: accessing a genuinely missing attribute still
    raises :py:class:`AttributeError`.

    c                óN   — | j                   j                  ›d|›�}t        |«      ‚)zARaise :py:class:`AttributeError` for a missing dynamic attribute.z object has no attribute )Ú	__class__Ú__name__ÚAttributeError)ÚselfÚ	attributeÚmsgs      úN/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/base.pyÚ__getattr__zDynamicAttributes.__getattr__   s)   € à—‘×(Ñ(Ð+Ð+DÀYÀMÐRˆÜ˜SÓ!Ð!ó    N)r   ÚstrÚreturnr   )r   Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r
   r
      s   „ ñô"r   r
   c                  óN   — e Zd ZdZedd„«       Zedd„«       Zed	d„«       Zd
d„Z	y)ÚPRAWBasez"Superclass for all models in PRAW.c                óX   — || v rt        | |   «      ni }|j                  |«       || |<   y)a*  Replace arguments[key] with a deepcopy and update.

        This method is often called when new parameters need to be added to a request.
        By calling this method and adding the new or updated parameters we can insure we
        don't modify the dictionary passed in by the caller.

        N)r   Úupdate)Ú	argumentsÚkeyÚnew_argumentsÚvalues       r   Ú_safely_add_argumentszPRAWBase._safely_add_arguments&   s0   € ð -0°9Ñ,<”˜ 3™Ô(À"ˆØ�‰�]Ô#Øˆ	�#Šr   c                óh   — t        j                  | t        j                  ¬«      j	                  «       S )a  Return ``timestamp`` as a timezone-aware :class:`datetime.datetime`.

        :param timestamp: A `Unix Time`_ value, in seconds.

        The returned object is localized to the system's timezone.

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

        )Útz)r   Úfromtimestampr   ÚutcÚ
astimezone)Ú	timestamps    r   Ú_to_local_datetimezPRAWBase._to_local_datetime3   s$   € ô ×%Ñ% i´H·L±LÔA×LÑLÓNÐNr   c                ó   —  | ||¬«      S )z™Return an instance of ``cls`` from ``data``.

        :param data: The structured data.
        :param reddit: An instance of :class:`.Reddit`.

        )Ú_datar   )ÚclsÚdataÚreddits      r   ÚparsezPRAWBase.parse@   s   € ñ �6 Ô&Ð&r   c                ób   — || _         |r&|j                  «       D ]  \  }}t        | ||«       Œ yy)zlInitialize a :class:`.PRAWBase` instance.

        :param reddit: An instance of :class:`.Reddit`.

        N)Ú_redditÚitemsÚsetattr)r   r/   r,   r   r"   s        r   Ú__init__zPRAWBase.__init__J   s9   € ð ˆŒÙØ$)§K¡K£Mò 0Ñ �	˜5Ü˜˜i¨Õ/ñ0ð r   N)r   údict[str, Any]r    r   r!   r   r   ÚNone)r)   Úfloatr   r   )r.   r6   r/   úpraw.Redditr   r   )r/   r9   r,   zdict[str, Any] | Noner   r7   )
r   r   r   r   Ústaticmethodr#   r*   Úclassmethodr0   r5   r   r   r   r   r   #   sF   „ Ù,àò
ó ð
ð ò
Oó ð
Oð ò'ó ð'ô	0r   r   )r   Ú
__future__r   Úcopyr   r   r   Útypingr   r   Úprawr
   r   r   r   r   ú<module>r@      s.   ðÙ &å "å ß 'ß %áÛ÷"ñ "÷,00ò 00r   