o
    2g                     @  sp   d Z ddlmZ ddl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ZG dd deZd
S )zProvide the RedditBase class.    )annotations)TYPE_CHECKINGAny)urlparse   )API_PATH)
InvalidURL   )PRAWBaseNc                      s   e Zd ZdZed/ddZd0ddZd1ddZd2ddZ			d3d4 fdd Z	d5d"d#Z
d6d$d%Zd6d&d'Zd(d) Zd*d+ Zd7d-d.Z  ZS )8
RedditBasez1Base class that represents actual Reddit objects.urlstrreturn	list[str]c                 C  s(   t | }|jst| |jddS )N/)r   netlocr   pathrstripsplit)r   parsed r   O/home/garg/my-data/venv/lib/python3.10/site-packages/praw/models/reddit/base.py
_url_parts   s   zRedditBase._url_partsother	Any | strboolc                 C  sB   t |tr| t|  kS t || jo t|  t| kS )z5Return whether the other instance equals the current.)
isinstancer   lower	__class__selfr   r   r   r   __eq__   s
   
zRedditBase.__eq__	attributer   c                 C  s<   | ds| js|   t| |S | jjd|}t|)z"Return the value of ``attribute``._z object has no attribute )
startswith_fetched_fetchgetattrr   __name__AttributeError)r    r"   msgr   r   r   __getattr__#   s
   
zRedditBase.__getattr__intc                 C  s   t | jjt t|  A S )z(Return the hash of the current instance.)hashr   r(   r   r   r    r   r   r   __hash__+   s   zRedditBase.__hash__NFTredditpraw.Reddit_datadict[str, Any] | None_extra_attribute_to_check
str | Noner%   
_str_fieldc                   sb   t  j||d || _|r-| j| jvr/|dur|| jv rdS d| j d| j d}t|dS dS )znInitialize a :class:`.RedditBase` instance.

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

        )r2   Nz#An invalid value was specified for z". Check that the argument for the z parameter is not empty.)super__init__r%   	STR_FIELD__dict__
ValueError)r    r0   r2   r4   r%   r6   r*   r   r   r   r8   /   s   
zRedditBase.__init__objectc                 C  s
   | |k S )z;Return whether the other instance differs from the current.r   r   r   r   r   __ne__G   s   
zRedditBase.__ne__c                 C  s    | j j d| j dt| dS )z?Return an object initialization representation of the instance.(=))r   r(   r9   r   r.   r   r   r   __repr__K   s    zRedditBase.__repr__c                 C  s   t | | jS )z/Return a string representation of the instance.)r'   r9   r.   r   r   r   __str__O   s   zRedditBase.__str__c                 C  s
   d| _ d S )NT)r%   r.   r   r   r   r&   S   s   
zRedditBase._fetchc                 C  s4   |   \}}}t| jdi |}| jjd||dS )NGET)methodparamsr   r   )_fetch_infor   format_redditrequest)r    namefieldsrF   r   r   r   r   _fetch_dataV   s   zRedditBase._fetch_data
attributesc                 G  s&   |D ]}|| j v r| j |= qd| _d S )NF)r:   r%   )r    rN   r"   r   r   r   _reset_attributes[   s
   

zRedditBase._reset_attributes)r   r   r   r   )r   r   r   r   )r"   r   r   r   )r   r,   )NFT)
r0   r1   r2   r3   r4   r5   r%   r   r6   r   )r   r=   r   r   )r   r   )rN   r   )r(   
__module____qualname____doc__staticmethodr   r!   r+   r/   r8   r>   rB   rC   r&   rM   rO   __classcell__r   r   r<   r   r      s"    

	



r   )rR   
__future__r   typingr   r   urllib.parser   	endpointsr   
exceptionsr   baser
   prawr   r   r   r   r   <module>   s    