Ë
    Fü´jõ  ã                  ó    — d Z ddlmZ ddlZddl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 dd
lmZ  G d„ d«      Z G d„ d«      Zy)zAProvides the code to load PRAW's configuration file ``praw.ini``.é    )ÚannotationsN)Úfiles)ÚPath)ÚLock)ÚMappingProxyType)ÚAny)Úwarn)ÚClientExceptionc                  ó    — e Zd Zdd„ZeZdd„Zy)Ú_NotSetc                 ó   — y)NF© ©Úselfs    úI/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/config.pyÚ__bool__z_NotSet.__bool__   s   € Øó    c                 ó   — y)NÚNotSetr   r   s    r   Ú__str__z_NotSet.__str__   s   € Ør   N)ÚreturnÚbool©r   Ústr)Ú__name__Ú
__module__Ú__qualname__r   Ú__nonzero__r   r   r   r   r   r      s   „ óð €Kôr   r   c                  ó~  — e Zd ZU dZdZded<    e«       Z ee	j                  e	j                  dœ«      Z e«       Zded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   edd„«       Ze	 	 	 	 d d„«       Zeddœd!d„«       Zed"d„«       Z	 d#	 	 	 	 	 	 	 d$d„Zd%d„Zddœd&d„Zd'd„Zd(d„Zy))ÚConfigz7A class containing the configuration for a Reddit site.Nz configparser.ConfigParser | NoneÚCONFIG)ÚbasicÚextendedr   Ú	client_idú
str | NoneÚclient_secretÚ	oauth_urlÚpasswordÚintÚratelimit_secondsÚ
reddit_urlÚredirect_uriÚrefresh_tokenÚtimeoutÚ
user_agentÚusernamec                ól   — t        | t        «      r| S t        | t        «      ry| j                  «       dv S )NF>   Ú1ÚonÚyesÚtrue)Ú
isinstancer   r   Úlower©Úitems    r   Ú_config_booleanzConfig._config_boolean4   s0   € ä�dœDÔ!ØˆKÜ�dœGÔ$ØØ�z‰z‹|Ð9Ð9Ð9r   c                ó   — t        j                  d«      ryt        d«      }|j                  «       syt	        j
                  | ¬«      }	 |j                  t        |«      «       t        |j                  «       «      }|j                  «       D ]"  }|j                  |j                  |«      «       Œ$ t        ddh|z  «      x}r2t        d|j!                  «       › dd	j#                  |«      › d
�d¬«       yy# t        j                  $ r Y yw xY w)af  Warn if a ``praw.ini`` in the current directory overrides OAuth endpoints.

        ``praw.ini`` is loaded from the current working directory, so a file planted
        there can redirect ``oauth_url`` or ``reddit_url`` to an attacker-controlled
        host and capture credentials. Legitimate configs almost never set these keys, so
        surface a warning when they do.

        The warning can be silenced by setting the ``PRAW_ALLOW_ENDPOINT_OVERRIDE``
        environment variable. It is intentionally not a ``praw.ini`` option, as that
        would let the planted file silence its own warning.

        ÚPRAW_ALLOW_ENDPOINT_OVERRIDENúpraw.ini©Úinterpolationr'   r+   z/The praw.ini in the current working directory (z) overrides the z and zs endpoint(s). Credentials will be sent to the configured host. Remove this file or these keys if it is not trusted.é   )Ú
stacklevel)ÚosÚgetenvr   Úis_fileÚconfigparserÚConfigParserÚreadr   ÚErrorÚsetÚdefaultsÚsectionsÚupdateÚoptionsÚsortedr	   ÚresolveÚjoin)Úinterpolator_classÚcwd_config_pathÚ
cwd_configÚkeys_presentÚsectionÚ
overriddens         r   Ú_warn_on_endpoint_overridez!Config._warn_on_endpoint_override<   s  € ô  �9‰9Ð3Ô4ØÜ˜zÓ*ˆØ×&Ñ&Ô(ØÜ!×.Ñ.Ð=OÔPˆ
ð	Ø�O‰OœC Ó0Ô1ô ˜:×.Ñ.Ó0Ó1ˆØ!×*Ñ*Ó,ò 	=ˆGØ×Ñ 
× 2Ñ 2°7Ó ;Õ<ð	=ä ¨lÐ ;¸lÑ JÓKÐKˆ:ÐKÜØAÀ/×BYÑBYÓB[ÐA\ð ]"Ø")§,¡,¨zÓ":Ð!;ð <ðð öð Løô ×!Ñ!ò 	Ùð	ús   Á
C7 Ã7DÄD©Úconfig_interpolationc               óÔ  — |� | j                   |   «       }nd}t        j                  |¬«      }t        €J ‚t	        t        «      j                  d«      j                  d«      5 }|j                  |«       ddd«       dt        j                  v rt        t        j                  d   «      }ncdt        j                  v rt        t        j                  d   «      }n4dt        j                  v r t        t        j                  d   «      dz  }nd}dg}|�|j                  d	t        |dz  «      «       | j                  |«       |j                  |«       || _        y# 1 sw Y   ŒèxY w)
z5Attempt to load settings from various praw.ini files.Nr>   r=   ÚrÚAPPDATAÚXDG_CONFIG_HOMEÚHOMEz.configr   )ÚINTERPOLATION_LEVELrE   rF   Ú__package__r   ÚjoinpathÚopenÚ	read_filerB   Úenvironr   Úinsertr   rW   rG   r!   )ÚclsrY   rQ   ÚconfigÚhdlÚos_config_pathÚ	locationss          r   Ú_load_configzConfig._load_configb   s:  € ð  Ð+Ø!N ×!8Ñ!8Ð9MÑ!NÓ!PÑà!%Ðä×*Ñ*Ð9KÔLˆÜÐ&Ð&Ð&Ü”;Ó×(Ñ(¨Ó4×9Ñ9¸#Ó>ð 	"À#Ø×Ñ˜SÔ!÷	"ð œŸ
™
Ñ"Ü!¤"§*¡*¨YÑ"7Ó8‰NØ¤"§*¡*Ñ,Ü!¤"§*¡*Ð->Ñ"?Ó@‰NØ”r—z‘zÑ!Ü!¤"§*¡*¨VÑ"4Ó5¸	ÑA‰Nà!ˆNà�Lˆ	àÐ%Ø×Ñ˜Q¤ N°ZÑ$?Ó @ÔAà×&Ñ&Ð'9Ô:Ø�‰�IÔØˆ�
÷'	"ð 	"ús   Á%EÅE'c                óh   — t        | j                  t        «      rd}t        |«      ‚| j                  S )zVThe short url.

        :raises: :class:`.ClientException` if it is not set.

        zNo short domain specified.)r6   Ú
_short_urlr   r
   )r   Úmsgs     r   Ú	short_urlzConfig.short_url�   s,   € ô �d—o‘o¤wÔ/Ø.ˆCÜ! #Ó&Ð&Ø�‰Ðr   c                ó@  — t         j                  5  t         j                  €| j                  |¬«       ddd«       || _        t         j                  €J ‚t        t         j                  j                  |«      fi |¤Ž| _        | j                  «        y# 1 sw Y   ŒaxY w)z'Initialize a :class:`.Config` instance.NrX   )	r    ÚLOCKr!   rk   Ú	_settingsÚdictÚitemsÚcustomÚ_initialize_attributes)r   Ú	site_namerY   Úsettingss       r   Ú__init__zConfig.__init__�   s…   € ô �[‰[ñ 	MÜ�}‰}Ð$Ø×!Ñ!Ð7KÐ!ÔL÷	Mð "ˆŒÜ�}‰}Ð(Ð(Ð(Üœ6Ÿ=™=×.Ñ.¨yÓ9ÑF¸XÑFˆŒà×#Ñ#Õ%÷	Mð 	Mús   ‘#BÂBc                ó>   — | j                   |   }| j                   |= |S ©N)ru   )r   ÚkeyÚvalues      r   Ú_fetchzConfig._fetchž   s!   € Ø—‘˜CÑ ˆØ�K‰K˜ÐØˆr   ©Údefaultc               óD   — || j                   vr|S | j                  |«      S r{   )ru   r~   )r   r|   r€   s      r   Ú_fetch_defaultzConfig._fetch_default£   s"   € Ø�d—k‘kÑ!ØˆNØ�{‰{˜3ÓÐr   c                óº   — || j                   v r| j                  |«      S t        j                  d|› �«      }| j	                  |«      }|xs |xs | j
                  S )NÚpraw_)rr   r~   rB   rC   r‚   ÚCONFIG_NOT_SET)r   r|   Ú	env_valueÚ	ini_values       r   Ú_fetch_or_not_setzConfig._fetch_or_not_set¨   sY   € Ø�$—.‘.Ñ Ø—;‘;˜sÓ#Ð#ä—I‘I  c U˜mÓ,ˆ	Ø×'Ñ'¨Ó,ˆ	ð Ò<˜IÒ<¨×)<Ñ)<Ð<r   c                óò  — | j                  d«      xs | j                  | _        | j                  | j                  dd¬«      ¬«      | _        | j                  | j                  d«      ¬«      | _        | j                  dd¬«      | _        d	D �ci c]  }|| j                  |› d
�«      “Œ c}| _	        dD ]  }t        | || j                  |«      «       Œ  dD ]  }t        | || j                  |«      «       Œ  t        t        dœj                  «       D ]#  \  }}	 t        | | |t        | |«      «      «       Œ% y c c}w # t        $ r- d|› d|j                  › dt        | |«      › d�}t        |«      d ‚w xY w)Nro   Úcheck_for_asyncTr   r8   Úcheck_for_updatesÚwindow_sizeiX  )ÚcommentÚmessageÚredditorÚ
submissionÚ	subredditÚtrophyÚ_kind)r$   r&   r,   r-   r(   r/   r0   )r'   r*   r+   r.   )r*   r.   z.An incorrect config type was given for option z. The expected type is z, but the given value is ú.)r‚   r…   rm   r:   rŠ   rˆ   r‹   rŒ   r~   ÚkindsÚsetattrr)   rt   ÚgetattrÚ
ValueErrorr   )r   ÚxÚ	attributeÚrequired_attributeÚ
conversionrn   s         r   rv   zConfig._initialize_attributes²   sÀ  € Ø×-Ñ-¨kÓ:ÒQ¸d×>QÑ>QˆŒØ#×3Ñ3¸×9LÑ9LÐM^ÐhlÐ9LÓ9mÐ3ÓnˆÔØ!%×!5Ñ!5¸4×;QÑ;QÐReÓ;fÐ!5Ó!gˆÔØ×.Ñ.¨}ÀcÐ.ÓJˆÔðö

àð ˆt�{‰{˜a˜S ˜;Ó'Ñ'ò

ˆŒ
ð
ò 		HˆIô �D˜) T×%;Ñ%;¸IÓ%FÕGð		Hð#
ò 	OÐô �DÐ,¨d¯k©kÐ:LÓ.MÕNð	Oô "%Üñ&
÷ ‰%‹'ò	0Ñ!ˆI�zð0Ü˜˜i©´G¸DÀ)Ó4LÓ)MÕNñ	0ùò?

øôJ ò 0ØFÀyÀkÐQhÐis×i|Ñi|Ðh}ð  ~Wô  X_ð  `dð  foó  Xpð  Wqð  qrð  s�Ü  “o¨4Ð/ð0ús   ÂD;ÄE Å 6E6)r9   zbool | str | _NotSetr   r   )rQ   z!configparser.Interpolation | Noner   ÚNone)rY   r%   r   r�   r   r{   )rw   r   rY   r%   rx   zstr | bool | int | Noner   r�   )r|   r   r   r   )r|   r   r€   zbool | float | str | Noner   r   )r|   r   r   zAny | _NotSet)r   r�   )r   r   r   Ú__doc__r!   Ú__annotations__r   r…   r   rE   ÚBasicInterpolationÚExtendedInterpolationr_   r   rq   Ústaticmethodr:   rW   Úclassmethodrk   Úpropertyro   ry   r~   r‚   rˆ   rv   r   r   r   r    r       s.  … ÙAà/3€FÐ,Ó3Ù“Y€NÙ*Ø×0Ñ0Ø ×6Ñ6ñ,ó Ðñ ‹6€Dð ƒNØÓØƒNØÓØÓØƒOØÓØÓØƒLØƒOØÓàò:ó ð:ð ð#Ø=ð#à	ò#ó ð#ðJ Ø@Dô ó ðð< ò	ó ð	ð ,0ð&àð&ð )ð&ð ,ð	&ð
 
ó&ó"ð
 PTõ  ó
=ô,0r   r    )rž   Ú
__future__r   rE   rB   Úimportlib.resourcesr   Úpathlibr   Ú	threadingr   Útypesr   Útypingr   Úwarningsr	   Úpraw.exceptionsr
   r   r    r   r   r   ú<module>r­      s<   ðÙ Gå "ã Û 	Ý %Ý Ý Ý "Ý Ý å +÷ñ ÷C0ò C0r   