
    {i                    d    S r SSKJr  SSKJr  SSKJr  SSKJr   " S S	\5      r	 " S
 S\5      r
g)zProvide poll-related classes.    )annotations)Any   )cachedproperty   )PRAWBasec                  ,    \ rS rSrSrSS jrSS jrSrg)
PollOption   a  Class to represent one option of a poll.

If ``submission`` is a poll :class:`.Submission`, access the poll's options like so:

.. code-block:: python

    poll_data = submission.poll_data

    # By index -- print the first option
    print(poll_data.options[0])

    # By ID -- print the option with ID "576797"
    print(poll_data.option("576797"))

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

============== =================================================
Attribute      Description
============== =================================================
``id``         ID of the poll option.
``text``       The text of the poll option.
``vote_count`` The number of votes the poll option has received.
============== =================================================

c                $    SU R                   < S3$ )z?Return an object initialization representation of the instance.zPollOption(id=))idselfs    Q/home/james-whalen/.local/lib/python3.13/site-packages/praw/models/reddit/poll.py__repr__PollOption.__repr__&   s    {!,,    c                    U R                   $ )z2Return a string version of the PollData, its text.)textr   s    r   __str__PollOption.__str__*   s    yyr    N)returnstr)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r
   r
      s    4-r   r
   c                  N   ^  \ rS rSrSr\SS j5       rSU 4S jjrS	S jrSr	U =r
$ )
PollData/   a  Class to represent poll data on a poll submission.

If ``submission`` is a poll :class:`.Submission`, access the poll data like so:

.. code-block:: python

    poll_data = submission.poll_data
    print(f"There are {poll_data.total_vote_count} votes total.")
    print("The options are:")
    for option in poll_data.options:
        print(f"{option} ({option.vote_count} votes)")
    print(f"I voted for {poll_data.user_selection}.")

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

======================== =========================================================
Attribute                Description
======================== =========================================================
``options``              A list of :class:`.PollOption` of the poll.
``total_vote_count``     The total number of votes cast in the poll.
``user_selection``       The poll option selected by the authenticated user
                         (possibly ``None``).
``voting_end_timestamp`` Time the poll voting closes, represented in `Unix Time`_.
======================== =========================================================

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

c                T    U R                   c  gU R                  U R                   5      $ )zGet the user's selection in this poll, if any.

:returns: The user's selection as a :class:`.PollOption`, or ``None`` if there
    is no choice.

N)_user_selectionoptionr   s    r   user_selectionPollData.user_selectionM   s(     '{{4//00r   c                   > US:X  a<  [        U[        5      (       a'  U Vs/ s H  n[        U R                  U5      PM     nnOUS:X  a  Sn[        TU ]  X5        gs  snf )z9Objectify the options attribute, and save user_selection.optionsr(   r&   N)
isinstancelistr
   _redditsuper__setattr__)r   	attributevaluer'   	__class__s       r   r0   PollData.__setattr__Y   sY    	!j&=&=DIJE&Zf5EEJE**)II- Ks    Ac                t    U R                    H  nUR                  U:X  d  M  Us  $    SU< S3n[        U5      e)zGet the option with the specified ID.

:param option_id: The ID of a poll option, as a ``str``.

:returns: The specified :class:`.PollOption`.

:raises: :py:class:`KeyError` if no option exists with the specified ID.

zNo poll option with ID .)r+   r   KeyError)r   	option_idr'   msgs       r   r'   PollData.optiona   s=     llFyyI% # (	}A6smr   r   )r   zPollOption | None)r1   r   r2   r   )r8   r   r   r
   )r   r   r   r   r    r   r(   r0   r'   r!   __classcell__)r3   s   @r   r#   r#   /   s+    : 	1 	1. r   r#   N)r    
__future__r   typingr   utilr   baser   r
   r#   r   r   r   <module>r@      s/    # "  " ! !HAx Ar   