ó
    T=Œj4  ã                  ó  • S r SSKJr  SSKrSSK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Jr  S	S
KJr  S	SKJr  \(       a  SSKJr  \R,                  S:X  a  SS jrOSSKJr   " S S\5      r " S S\\5      rSS jrSS jrS/rg)zUnix.é    )ÚannotationsN)ÚConfigParser)Úcached_property)ÚPath)Ú
gettempdir)ÚTYPE_CHECKINGÚNoReturné   )ÚXDGMixin)ÚPlatformDirsABC)ÚIteratorÚwin32c                 ó   • Sn [        U 5      e)Nzshould only be used on Unix)ÚRuntimeError)Úmsgs    Úa/Users/stevendouglas/BidBrain/.venv/lib/python3.13/site-packages/pip/_vendor/platformdirs/unix.pyÚgetuidr      s   € Ø+ˆÜ˜3ÓÐó    )r   c                  ó¬  • \ rS rSrSr\S'S j5       r\S(S j5       r\S)S j5       r	\S(S j5       r
\S)S j5       r\S(S j5       r\S(S	 j5       r\S(S
 j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S(S j5       r\S)S j5       r \S(S j5       r!\S(S j5       r"\S(S j5       r#\S*S  j5       r$\S*S! j5       r%\S*S" j5       r&S+S# jr'S+S$ jr(S%r)g&),Ú_UnixDefaultsé   z–Default directories for Unix/Linux without XDG environment variable overrides.

The XDG env var handling is in :class:`~platformdirs._xdg.XDGMixin`.

c                óB   • U R                   =(       a    [        5       S:H  $ )Nr   )Úuse_site_for_rootr   ©Úselfs    r   Ú	_use_siteÚ_UnixDefaults._use_site$   s   € à×%Ñ%×7¬&«(°a©-Ð7r   c                ó^   • U R                  [        R                  R                  S5      5      $ )z|:returns: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or ``$XDG_DATA_HOME/$appname/$version``ú~/.local/share©Ú_append_app_name_and_versionÚosÚpathÚ
expanduserr   s    r   Úuser_data_dirÚ_UnixDefaults.user_data_dir(   ó%   € ð ×0Ñ0´·±×1CÑ1CÐDTÓ1UÓVÐVr   c                óF   • U R                  S5      U R                  S5      /$ )Nú/usr/local/shareú
/usr/share©r!   r   s    r   Ú_site_data_dirsÚ_UnixDefaults._site_data_dirs-   s%   € à×1Ñ1Ð2DÓEÀt×GhÑGhÐiuÓGvÐwÐwr   c                ó^   • U R                  [        R                  R                  S5      5      $ )z{:returns: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or ``$XDG_CONFIG_HOME/$appname/$version``ú	~/.configr    r   s    r   Úuser_config_dirÚ_UnixDefaults.user_config_dir1   s$   € ð ×0Ñ0´·±×1CÑ1CÀKÓ1PÓQÐQr   c                ó&   • U R                  S5      /$ )Nz/etc/xdgr+   r   s    r   Ú_site_config_dirsÚ_UnixDefaults._site_config_dirs6   s   € à×1Ñ1°*Ó=Ð>Ð>r   c                ó^   • U R                  [        R                  R                  S5      5      $ )zx:returns: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or ``$XDG_CACHE_HOME/$appname/$version``z~/.cacher    r   s    r   Úuser_cache_dirÚ_UnixDefaults.user_cache_dir:   s$   € ð ×0Ñ0´·±×1CÑ1CÀJÓ1OÓPÐPr   c                ó$   • U R                  S5      $ )zP:returns: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z
/var/cacher+   r   s    r   Úsite_cache_dirÚ_UnixDefaults.site_cache_dir?   s   € ð ×0Ñ0°Ó>Ð>r   c                ó^   • U R                  [        R                  R                  S5      5      $ )z~:returns: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or ``$XDG_STATE_HOME/$appname/$version``z~/.local/stater    r   s    r   Úuser_state_dirÚ_UnixDefaults.user_state_dirD   r'   r   c                ó$   • U R                  S5      $ )zN:returns: state directory shared by users, e.g. ``/var/lib/$appname/$version``z/var/libr+   r   s    r   Úsite_state_dirÚ_UnixDefaults.site_state_dirI   s   € ð ×0Ñ0°Ó<Ð<r   c                ó¢   • U R                   nU R                  (       a1  [        R                  R	                  US5      nU R                  U5        U$ )zh:returns: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itÚlog)r<   Úopinionr"   r#   ÚjoinÚ_optionally_create_directory©r   r#   s     r   Úuser_log_dirÚ_UnixDefaults.user_log_dirN   s=   € ð ×"Ñ"ˆØ�<�<Ü—7‘7—<‘<  eÓ,ˆDØ×-Ñ-¨dÔ3Øˆr   c                ó$   • U R                  S5      $ )z²:returns: log directory shared by users, e.g. ``/var/log/$appname/$version``

Unlike `user_log_dir`, ``opinion`` has no effect since ``/var/log`` is inherently a log directory.

z/var/logr+   r   s    r   Úsite_log_dirÚ_UnixDefaults.site_log_dirW   s   € ð ×0Ñ0°Ó<Ð<r   c                ó   • [        SS5      $ )zD:returns: documents directory tied to the user, e.g. ``~/Documents``ÚXDG_DOCUMENTS_DIRz~/Documents©Ú_get_user_media_dirr   s    r   Úuser_documents_dirÚ _UnixDefaults.user_documents_dir`   ó   € ô #Ð#6¸ÓFÐFr   c                ó   • [        SS5      $ )zD:returns: downloads directory tied to the user, e.g. ``~/Downloads``ÚXDG_DOWNLOAD_DIRz~/DownloadsrN   r   s    r   Úuser_downloads_dirÚ _UnixDefaults.user_downloads_dire   s   € ô #Ð#5°}ÓEÐEr   c                ó   • [        SS5      $ )zB:returns: pictures directory tied to the user, e.g. ``~/Pictures``ÚXDG_PICTURES_DIRz
~/PicturesrN   r   s    r   Úuser_pictures_dirÚ_UnixDefaults.user_pictures_dirj   ó   € ô #Ð#5°|ÓDÐDr   c                ó   • [        SS5      $ )z>:returns: videos directory tied to the user, e.g. ``~/Videos``ÚXDG_VIDEOS_DIRz~/VideosrN   r   s    r   Úuser_videos_dirÚ_UnixDefaults.user_videos_diro   s   € ô #Ð#3°ZÓ@Ð@r   c                ó   • [        SS5      $ )z<:returns: music directory tied to the user, e.g. ``~/Music``ÚXDG_MUSIC_DIRz~/MusicrN   r   s    r   Úuser_music_dirÚ_UnixDefaults.user_music_dirt   s   € ô # ?°IÓ>Ð>r   c                ó   • [        SS5      $ )z@:returns: desktop directory tied to the user, e.g. ``~/Desktop``ÚXDG_DESKTOP_DIRz	~/DesktoprN   r   s    r   Úuser_desktop_dirÚ_UnixDefaults.user_desktop_diry   s   € ô #Ð#4°kÓBÐBr   c                ó   • [        SS5      $ )zB:returns: projects directory tied to the user, e.g. ``~/Projects``ÚXDG_PROJECTS_DIRz
~/ProjectsrN   r   s    r   Úuser_projects_dirÚ_UnixDefaults.user_projects_dir~   r[   r   c                ó   • [        SS5      $ )zD:returns: public share directory tied to the user, e.g. ``~/Public``ÚXDG_PUBLICSHARE_DIRz~/PublicrN   r   s    r   Úuser_publicshare_dirÚ"_UnixDefaults.user_publicshare_dirƒ   s   € ô #Ð#8¸*ÓEÐEr   c                ó   • [        SS5      $ )zD:returns: templates directory tied to the user, e.g. ``~/Templates``ÚXDG_TEMPLATES_DIRz~/TemplatesrN   r   s    r   Úuser_templates_dirÚ _UnixDefaults.user_templates_dirˆ   rR   r   c                óF   • [         R                  R                  S5       S3$ )zI:returns: fonts directory tied to the user, e.g. ``~/.local/share/fonts``r   z/fonts©r"   r#   r$   r   s    r   Úuser_fonts_dirÚ_UnixDefaults.user_fonts_dir�   s"   € ô —'‘'×$Ñ$Ð%5Ó6Ð7°vÐ>Ð>r   c                ó   • U R                   $ )zL:returns: preference directory tied to the user, same as ``user_config_dir``)r0   r   s    r   Úuser_preference_dirÚ!_UnixDefaults.user_preference_dir’   s   € ð ×#Ñ#Ð#r   c                ó@   • [         R                  R                  S5      $ )z?:returns: bin directory tied to the user, e.g. ``~/.local/bin``z~/.local/binru   r   s    r   Úuser_bin_dirÚ_UnixDefaults.user_bin_dir—   s   € ô �w‰w×!Ñ! .Ó1Ð1r   c                ó   • g)z@:returns: bin directory shared by users, e.g. ``/usr/local/bin``z/usr/local/bin© r   s    r   Úsite_bin_dirÚ_UnixDefaults.site_bin_dirœ   s   € ð  r   c                ó|   • [         R                  R                  [         R                  R                  S5      S5      $ )zW:returns: applications directory tied to the user, e.g. ``~/.local/share/applications``r   Úapplications)r"   r#   rD   r$   r   s    r   Úuser_applications_dirÚ#_UnixDefaults.user_applications_dir¡   s)   € ô �w‰w�|‰|œBŸG™G×.Ñ.Ð/?Ó@À.ÓQÐQr   c                ón   • S Vs/ s H#  n[         R                  R                  US5      PM%     sn$ s  snf )N)r)   r*   rƒ   )r"   r#   rD   )r   Úps     r   Ú_site_applications_dirsÚ%_UnixDefaults._site_applications_dirs¦   s+   € á9[Ó\Ò9[°A”—‘—‘˜Q Ö/Ñ9[Ñ\Ð\ùÒ\s   …*2c                ó„   • U R                   nU R                  (       a  [        R                  R	                  U5      $ US   $ )zR:returns: applications directory shared by users, e.g. ``/usr/share/applications``r   )rˆ   Ú	multipathr"   ÚpathseprD   )r   Údirss     r   Úsite_applications_dirÚ#_UnixDefaults.site_applications_dirª   s1   € ð ×+Ñ+ˆØ(,¯¯Œr�z‰z�‰˜tÓ$ÐC¸DÀ¹GÐCr   c                óˆ  • [         R                  R                  S5      (       a  S[        5        3nO?[         R                  R                  S5      (       a  S[        5        3nOS[        5        3n[        R
                  " U[        R                  5      (       d  [        5        S[        5        3nU R                  U5      $ )aX  :returns: runtime directory tied to the user, e.g. ``$XDG_RUNTIME_DIR/$appname/$version``.

If ``$XDG_RUNTIME_DIR`` is unset, tries the platform default (``/tmp/run/user/$(id -u)`` on OpenBSD, ``/var/run/user/$(id -u)`` on FreeBSD/NetBSD, ``/run/user/$(id -u)`` otherwise). If the default is not writable, falls back to a temporary directory.

Úopenbsdz/tmp/run/user/)ÚfreebsdÚnetbsdz/var/run/user/z
/run/user/z	/runtime-)	ÚsysÚplatformÚ
startswithr   r"   ÚaccessÚW_OKr   r!   rF   s     r   Úuser_runtime_dirÚ_UnixDefaults.user_runtime_dir°   s“   € ô �<‰<×"Ñ" 9×-Ñ-Ø#¤F£H :Ð.‰DÜ�\‰\×$Ñ$Ð%:×;Ñ;Ø#¤F£H :Ð.‰Dà¤£˜zÐ*ˆDÜ�yŠy˜œrŸw™w×'Ñ'Ü “l�^ 9¬V«X¨JÐ7ˆDØ×0Ñ0°Ó6Ð6r   c                óv   • [         R                  R                  S5      (       a  SnOSnU R                  U5      $ )a.  :returns: runtime directory shared by users, e.g. ``/run/$appname/$version`` or ``$XDG_RUNTIME_DIR/$appname/$version``.

Note that this behaves almost exactly like `user_runtime_dir` if ``$XDG_RUNTIME_DIR`` is set, but will fall back to paths associated to the root user instead of a regular logged-in user if it's not set.

If you wish to ensure that a logged-in root user path is returned e.g. ``/run/user/0``, use `user_runtime_dir` instead.

For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/$appname/$version`` if ``$XDG_RUNTIME_DIR`` is not set.

)r’   r‘   r“   z/var/runz/run)r”   r•   r–   r!   rF   s     r   Úsite_runtime_dirÚ_UnixDefaults.site_runtime_dirÁ   s5   € ô �<‰<×"Ñ"Ð#C×DÑDØ‰DàˆDØ×0Ñ0°Ó6Ð6r   c                ó8   • U R                  U R                  5      $ )zi:returns: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)Ú _first_item_as_path_if_multipathÚsite_data_dirr   s    r   Úsite_data_pathÚ_UnixDefaults.site_data_pathÒ   s   € ð ×4Ñ4°T×5GÑ5GÓHÐHr   c                ó8   • U R                  U R                  5      $ )zg:returns: config path shared by users, returns the first item, even if ``multipath`` is set to ``True``)rŸ   Úsite_config_dirr   s    r   Úsite_config_pathÚ_UnixDefaults.site_config_path×   s   € ð ×4Ñ4°T×5IÑ5IÓJÐJr   c                ó8   • U R                  U R                  5      $ )zj:returns: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)rŸ   r9   r   s    r   Úsite_cache_pathÚ_UnixDefaults.site_cache_pathÜ   s   € ð ×4Ñ4°T×5HÑ5HÓIÐIr   c              #  óv   #   • U R                   (       d  U R                  v •  U R                   Sh  v•N   g N7f)z4:yield: all user and site configuration directories.N)r   r0   r3   r   s    r   Úiter_config_dirsÚ_UnixDefaults.iter_config_dirsá   s'   é € à�~�~Ø×&Ñ&Ò&Ø×)Ñ)×)Ó)ùó   ‚/9±7²9c              #  óv   #   • U R                   (       d  U R                  v •  U R                   Sh  v•N   g N7f)z+:yield: all user and site data directories.N)r   r%   r,   r   s    r   Úiter_data_dirsÚ_UnixDefaults.iter_data_dirsç   s'   é € à�~�~Ø×$Ñ$Ò$Ø×'Ñ'×'Ó'ùr­   r   N)ÚreturnÚbool©r±   Ústr)r±   z	list[str])r±   r   )r±   zIterator[str])*Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Úpropertyr%   r,   r0   r3   r6   r9   r<   r?   rG   rJ   rP   rU   rY   r^   rb   rf   rj   rn   rr   rv   ry   r|   r€   r„   rˆ   rŽ   r™   rœ   r¡   r¥   r¨   r«   r¯   Ú__static_attributes__r   r   r   r   r      s·  † ñð ó8ó ð8ð óWó ðWð óxó ðxð óRó ðRð ó?ó ð?ð óQó ðQð ó?ó ð?ð óWó ðWð ó=ó ð=ð óó ðð ó=ó ð=ð óGó ðGð óFó ðFð óEó ðEð óAó ðAð ó?ó ð?ð óCó ðCð óEó ðEð óFó ðFð óGó ðGð ó?ó ð?ð ó$ó ð$ð ó2ó ð2ð ó ó ð ð óRó ðRð ó]ó ð]ð óDó ðDð
 ó7ó ð7ð  ó7ó ð7ð  óIó ðIð óKó ðKð óJó ðJô*÷(r   r   c                  óð   ^ • \ rS rSrSr\SU 4S jj5       r\SU 4S jj5       r\SU 4S jj5       r\SU 4S jj5       r	\SU 4S jj5       r
\SU 4S jj5       r\SU 4S	 jj5       r\SU 4S
 jj5       rSrU =r$ )ÚUnixéî   aN  On Unix/Linux, we follow the `XDG Basedir Spec <https://specifications.freedesktop.org/basedir/latest/>`_.

The spec allows overriding directories with environment variables. The examples shown are the default values,
alongside the name of the environment variable that overrides them. Makes use of the `appname
<platformdirs.api.PlatformDirsABC.appname>`, `version <platformdirs.api.PlatformDirsABC.version>`, `multipath
<platformdirs.api.PlatformDirsABC.multipath>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
<platformdirs.api.PlatformDirsABC.ensure_exists>`.

c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )zb:returns: data directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r    Úsuperr%   ©r   Ú	__class__s    €r   r%   ÚUnix.user_data_dirù   s!   ø€ ð &*§^§^ˆt×!Ñ!ÐN¼¹Ñ9NÐNr   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )zd:returns: config directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r¤   rÀ   r0   rÁ   s    €r   r0   ÚUnix.user_config_dirþ   s!   ø€ ð (,§~§~ˆt×#Ñ#ÐR¼5¹7Ñ;RÐRr   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )zc:returns: cache directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r9   rÀ   r6   rÁ   s    €r   r6   ÚUnix.user_cache_dir  ó!   ø€ ð '+§n§nˆt×"Ñ"ÐP¼%¹'Ñ:PÐPr   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )zc:returns: state directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r?   rÀ   r<   rÁ   s    €r   r<   ÚUnix.user_state_dir  rÈ   r   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )za:returns: log directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   rJ   rÀ   rG   rÁ   s    €r   rG   ÚUnix.user_log_dir  ó!   ø€ ð %)§N§Nˆt× Ñ ÐL¼¹Ñ8LÐLr   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )zj:returns: applications directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   rŽ   rÀ   r„   rÁ   s    €r   r„   ÚUnix.user_applications_dir  s!   ø€ ð .2¯^¯^ˆt×)Ñ)Ð^ÄÁÑA^Ð^r   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )ze:returns: runtime directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   rœ   rÀ   r™   rÁ   s    €r   r™   ÚUnix.user_runtime_dir  s!   ø€ ð )-¯¯ˆt×$Ñ$ÐT¼E¹GÑ<TÐTr   c                óR   >• U R                   (       a  U R                  $ [        TU ]  $ )za:returns: bin directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r€   rÀ   r|   rÁ   s    €r   r|   ÚUnix.user_bin_dir  rÍ   r   r   r³   )rµ   r¶   r·   r¸   r¹   rº   r%   r0   r6   r<   rG   r„   r™   r|   r»   Ú__classcell__)rÂ   s   @r   r½   r½   î   s¸   ø† ñð öOó ðOð öSó ðSð öQó ðQð öQó ðQð öMó ðMð ö_ó ð_ð öUó ðUð öMó öMr   r½   c                óh   • [        U 5      =n(       a  U$ [        R                  R                  U5      $ )N)Ú_get_user_dirs_folderr"   r#   r$   )Úenv_varÚfallback_tilde_pathÚ	media_dirs      r   rO   rO   "  s.   € Ü)¨'Ó2Ð2€yÕ2ØÐÜ�7‰7×ÑÐ1Ó2Ð2r   c                ó<  • [         R                  R                  SS5      R                  5       =(       d    [         R                  R                  S5      n[        U5      S-  nUR                  5       (       a”  [        5       nUR                  5        nUR                  SUR                  5        35        SSS5        XS   ;  a  gUS   U    R                  S5      nUR                  S	[         R                  R                  S
5      5      $ g! , (       d  f       N^= f)znReturn directory from user-dirs.dirs config file.

See https://freedesktop.org/wiki/Software/xdg-user-dirs/.

ÚXDG_CONFIG_HOMEÚ r/   zuser-dirs.dirsz[top]
NÚtopÚ"z$HOMEÚ~)r"   ÚenvironÚgetÚstripr#   r$   r   Úexistsr   ÚopenÚread_stringÚreadÚreplace)ÚkeyÚconfig_homeÚuser_dirs_config_pathÚparserÚstreamr#   s         r   rÖ   rÖ   (  sà   € ô —*‘*—.‘.Ð!2°BÓ7×=Ñ=Ó?×bÄ2Ç7Á7×CUÑCUÐVaÓCb€KÜ  Ó-Ð0@Ñ@ÐØ×#Ñ#×%Ñ%Ü“ˆà"×'Ñ'Ô)¨VØ×Ñ ¨¯©«¨Ð8Ô9÷ *ð ˜U‘mÓ#Øà�e‰}˜SÑ!×'Ñ'¨Ó,ˆØ�|‰|˜G¤R§W¡W×%7Ñ%7¸Ó%<Ó=Ð=à÷ *Õ)ús   Â#DÄ
D)r±   r	   )r×   r´   rØ   r´   r±   r´   )rè   r´   r±   z
str | None)r¹   Ú
__future__r   r"   r”   Úconfigparserr   Ú	functoolsr   Úpathlibr   Útempfiler   Útypingr   r	   Ú_xdgr   Úapir   Úcollections.abcr   r•   r   r   r½   rO   rÖ   Ú__all__r   r   r   Ú<module>r÷      sx   ðÙ å "ã 	Û 
Ý %Ý %Ý Ý ß *å Ý  æÝ(à‡<�<�7Óõ õ
 ôN(�Oô N(ôb1Mˆ8�]ô 1Môh3ôð0 ð�r   