Ë
    ÅÍáj4  ã                  ó  — 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mZ d	d
lmZ d	dlmZ erddlmZ ej,                  dk(  rdd„ZnddlmZ  G d„ de«      Z G d„ dee«      Zdd„Zdd„ZdgZy)zUnix.é    )ÚannotationsN)ÚConfigParser)Úcached_property)ÚPath)Ú
gettempdir)ÚTYPE_CHECKINGÚNoReturné   )ÚXDGMixin)ÚPlatformDirsABC)ÚIteratorÚwin32c                 ó   — d} t        | «      ‚)Nzshould only be used on Unix)ÚRuntimeError)Úmsgs    úU/data/www/html/cgi-venv/lib/python3.12/site-packages/pip/_vendor/platformdirs/unix.pyÚgetuidr      s   € Ø+ˆÜ˜3ÓÐó    )r   c                  ó`  — e Zd ZdZed%d„«       Zed&d„«       Zed'd„«       Zed&d„«       Z	ed'd„«       Z
ed&d„«       Zed&d„«       Zed&d	„«       Zed&d
„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed&d„«       Zed'd„«       Zed&d„«       Z ed&d„«       Z!ed&d„«       Z"ed(d„«       Z#ed(d „«       Z$ed(d!„«       Z%d)d"„Z&d)d#„Z'y$)*Ú_UnixDefaultszžDefault directories for Unix/Linux without XDG environment variable overrides.

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

    c                ó8   — | j                   xr t        «       dk(  S )Nr   )Úuse_site_for_rootr   ©Úselfs    r   Ú	_use_sitez_UnixDefaults._use_site$   s   € à×%Ñ%Ò7¬&«(°a©-Ð7r   c                ó^   — | j                  t        j                  j                  d«      «      S )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_dirz_UnixDefaults.user_data_dir(   ó%   € ð ×0Ñ0´·±×1CÑ1CÐDTÓ1UÓVÐVr   c                óF   — | j                  d«      | j                  d«      gS )Nú/usr/local/shareú
/usr/share©r   r   s    r   Ú_site_data_dirsz_UnixDefaults._site_data_dirs-   s%   € à×1Ñ1Ð2DÓEÀt×GhÑGhÐiuÓGvÐwÐwr   c                ó^   — | j                  t        j                  j                  d«      «      S )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_dirz_UnixDefaults.user_config_dir1   s$   € ð ×0Ñ0´·±×1CÑ1CÀKÓ1PÓQÐQr   c                ó&   — | j                  d«      gS )Nz/etc/xdgr(   r   s    r   Ú_site_config_dirsz_UnixDefaults._site_config_dirs6   s   € à×1Ñ1°*Ó=Ð>Ð>r   c                ó^   — | j                  t        j                  j                  d«      «      S )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_dirz_UnixDefaults.user_cache_dir:   s$   € ð ×0Ñ0´·±×1CÑ1CÀJÓ1OÓPÐPr   c                ó$   — | j                  d«      S )zP:returns: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z
/var/cacher(   r   s    r   Úsite_cache_dirz_UnixDefaults.site_cache_dir?   s   € ð ×0Ñ0°Ó>Ð>r   c                ó^   — | j                  t        j                  j                  d«      «      S )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_dirz_UnixDefaults.user_state_dirD   r$   r   c                ó$   — | j                  d«      S )zN:returns: state directory shared by users, e.g. ``/var/lib/$appname/$version``z/var/libr(   r   s    r   Úsite_state_dirz_UnixDefaults.site_state_dirI   s   € ð ×0Ñ0°Ó<Ð<r   c                ó˜   — | j                   }| j                  r1t        j                  j	                  |d«      }| j                  |«       |S )zh:returns: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itÚlog)r4   Úopinionr    r!   ÚjoinÚ_optionally_create_directory©r   r!   s     r   Úuser_log_dirz_UnixDefaults.user_log_dirN   s=   € ð ×"Ñ"ˆØ�<Š<Ü—7‘7—<‘<  eÓ,ˆDØ×-Ñ-¨dÔ3Øˆr   c                ó$   — | j                  d«      S )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_dirz_UnixDefaults.site_log_dirW   s   € ð ×0Ñ0°Ó<Ð<r   c                ó   — t        dd«      S )zD:returns: documents directory tied to the user, e.g. ``~/Documents``ÚXDG_DOCUMENTS_DIRz~/Documents©Ú_get_user_media_dirr   s    r   Úuser_documents_dirz _UnixDefaults.user_documents_dir`   ó   € ô #Ð#6¸ÓFÐFr   c                ó   — t        dd«      S )zD:returns: downloads directory tied to the user, e.g. ``~/Downloads``ÚXDG_DOWNLOAD_DIRz~/DownloadsrB   r   s    r   Úuser_downloads_dirz _UnixDefaults.user_downloads_dire   s   € ô #Ð#5°}ÓEÐEr   c                ó   — t        dd«      S )zB:returns: pictures directory tied to the user, e.g. ``~/Pictures``ÚXDG_PICTURES_DIRz
~/PicturesrB   r   s    r   Úuser_pictures_dirz_UnixDefaults.user_pictures_dirj   ó   € ô #Ð#5°|ÓDÐDr   c                ó   — t        dd«      S )z>:returns: videos directory tied to the user, e.g. ``~/Videos``ÚXDG_VIDEOS_DIRz~/VideosrB   r   s    r   Úuser_videos_dirz_UnixDefaults.user_videos_diro   s   € ô #Ð#3°ZÓ@Ð@r   c                ó   — t        dd«      S )z<:returns: music directory tied to the user, e.g. ``~/Music``ÚXDG_MUSIC_DIRz~/MusicrB   r   s    r   Úuser_music_dirz_UnixDefaults.user_music_dirt   s   € ô # ?°IÓ>Ð>r   c                ó   — t        dd«      S )z@:returns: desktop directory tied to the user, e.g. ``~/Desktop``ÚXDG_DESKTOP_DIRz	~/DesktoprB   r   s    r   Úuser_desktop_dirz_UnixDefaults.user_desktop_diry   s   € ô #Ð#4°kÓBÐBr   c                ó   — t        dd«      S )zB:returns: projects directory tied to the user, e.g. ``~/Projects``ÚXDG_PROJECTS_DIRz
~/ProjectsrB   r   s    r   Úuser_projects_dirz_UnixDefaults.user_projects_dir~   rL   r   c                ó   — t        dd«      S )zD:returns: public share directory tied to the user, e.g. ``~/Public``ÚXDG_PUBLICSHARE_DIRz~/PublicrB   r   s    r   Úuser_publicshare_dirz"_UnixDefaults.user_publicshare_dirƒ   s   € ô #Ð#8¸*ÓEÐEr   c                ó   — t        dd«      S )zD:returns: templates directory tied to the user, e.g. ``~/Templates``ÚXDG_TEMPLATES_DIRz~/TemplatesrB   r   s    r   Úuser_templates_dirz _UnixDefaults.user_templates_dirˆ   rE   r   c                óF   — t         j                  j                  d«      › d�S )zI:returns: fonts directory tied to the user, e.g. ``~/.local/share/fonts``r   z/fonts©r    r!   r"   r   s    r   Úuser_fonts_dirz_UnixDefaults.user_fonts_dir�   s"   € ô —'‘'×$Ñ$Ð%5Ó6Ð7°vÐ>Ð>r   c                ó   — | j                   S )zL:returns: preference directory tied to the user, same as ``user_config_dir``)r,   r   s    r   Úuser_preference_dirz!_UnixDefaults.user_preference_dir’   s   € ð ×#Ñ#Ð#r   c                ó@   — t         j                  j                  d«      S )z?:returns: bin directory tied to the user, e.g. ``~/.local/bin``z~/.local/binr`   r   s    r   Úuser_bin_dirz_UnixDefaults.user_bin_dir—   s   € ô �w‰w×!Ñ! .Ó1Ð1r   c                 ó   — y)z@:returns: bin directory shared by users, e.g. ``/usr/local/bin``z/usr/local/bin© r   s    r   Úsite_bin_dirz_UnixDefaults.site_bin_dirœ   s   € ð  r   c                ó|   — t         j                  j                  t         j                  j                  d«      d«      S )zW:returns: applications directory tied to the user, e.g. ``~/.local/share/applications``r   Úapplications)r    r!   r:   r"   r   s    r   Úuser_applications_dirz#_UnixDefaults.user_applications_dir¡   s)   € ô �w‰w�|‰|œBŸG™G×.Ñ.Ð/?Ó@À.ÓQÐQr   c                óh   — dD �cg c]"  }t         j                  j                  |d«      ‘Œ$ c}S c c}w )N)r&   r'   rj   )r    r!   r:   )r   Úps     r   Ú_site_applications_dirsz%_UnixDefaults._site_applications_dirs¦   s%   € à9[Ö\°A”—‘—‘˜Q Õ/Ò\Ð\ùÒ\s   …'/c                óz   — | j                   }| j                  rt        j                  j	                  |«      S |d   S )zR:returns: applications directory shared by users, e.g. ``/usr/share/applications``r   )rn   Ú	multipathr    Úpathsepr:   )r   Údirss     r   Úsite_applications_dirz#_UnixDefaults.site_applications_dirª   s1   € ð ×+Ñ+ˆØ(,¯ªŒr�z‰z�‰˜tÓ$ÐC¸DÀ¹GÐCr   c                óh  — t         j                  j                  d«      rdt        «       › �}n:t         j                  j                  d«      rdt        «       › �}ndt        «       › �}t	        j
                  |t        j                  «      st        «       › dt        «       › �}| j                  |«      S )ah  :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   r<   s     r   Úuser_runtime_dirz_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                ól   — t         j                  j                  d«      rd}nd}| j                  |«      S )aN  :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.

        )rv   ru   rw   z/var/runz/run)rx   ry   rz   r   r<   s     r   Úsite_runtime_dirz_UnixDefaults.site_runtime_dirÁ   s2   € ô �<‰<×"Ñ"Ð#CÔDØ‰DàˆDØ×0Ñ0°Ó6Ð6r   c                ó8   — | j                  | j                  «      S )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_pathz_UnixDefaults.site_data_pathÒ   s   € ð ×4Ñ4°T×5GÑ5GÓHÐHr   c                ó8   — | j                  | j                  «      S )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_pathz_UnixDefaults.site_config_path×   s   € ð ×4Ñ4°T×5IÑ5IÓJÐJr   c                ó8   — | j                  | j                  «      S )zj:returns: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)r�   r2   r   s    r   Úsite_cache_pathz_UnixDefaults.site_cache_pathÜ   s   € ð ×4Ñ4°T×5HÑ5HÓIÐIr   c              #  ól   K  — | j                   s| j                  –— | j                  E d{  –—†  y7 Œ­w)z4:yield: all user and site configuration directories.N)r   r,   r.   r   s    r   Úiter_config_dirsz_UnixDefaults.iter_config_dirsá   s(   è ø€ à�~Š~Ø×&Ñ&Ò&Ø×)Ñ)×)Ò)úó   ‚*4¬2­4c              #  ól   K  — | j                   s| j                  –— | j                  E d{  –—†  y7 Œ­w)z+:yield: all user and site data directories.N)r   r#   r)   r   s    r   Úiter_data_dirsz_UnixDefaults.iter_data_dirsç   s(   è ø€ à�~Š~Ø×$Ñ$Ò$Ø×'Ñ'×'Ò'úr‹   N)ÚreturnÚbool©rŽ   Ústr)rŽ   z	list[str])rŽ   r   )rŽ   zIterator[str])(Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úpropertyr#   r)   r,   r.   r0   r2   r4   r6   r=   r?   rD   rH   rK   rO   rR   rU   rX   r[   r^   ra   rc   re   rh   rk   rn   rs   r}   r   rƒ   r†   rˆ   rŠ   r�   rg   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                  óÈ   ‡ — e Zd ZdZed
ˆ fd„«       Zed
ˆ fd„«       Zed
ˆ fd„«       Zed
ˆ fd„«       Zed
ˆ fd„«       Z	ed
ˆ fd„«       Z
ed
ˆ fd„«       Zed
ˆ fd	„«       Zˆ xZS )ÚUnixaf  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                óH   •— | j                   r| j                  S t        ‰| �  S )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#   zUnix.user_data_dirù   s!   ø€ ð &*§^¢^ˆt×!Ñ!ÐN¼¹Ñ9NÐNr   c                óH   •— | j                   r| j                  S t        ‰| �  S )zd:returns: config directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r…   rš   r,   r›   s    €r   r,   zUnix.user_config_dirþ   s!   ø€ ð (,§~¢~ˆt×#Ñ#ÐR¼5¹7Ñ;RÐRr   c                óH   •— | j                   r| j                  S t        ‰| �  S )zc:returns: cache directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r2   rš   r0   r›   s    €r   r0   zUnix.user_cache_dir  ó!   ø€ ð '+§n¢nˆt×"Ñ"ÐP¼%¹'Ñ:PÐPr   c                óH   •— | j                   r| j                  S t        ‰| �  S )zc:returns: state directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r6   rš   r4   r›   s    €r   r4   zUnix.user_state_dir  rŸ   r   c                óH   •— | j                   r| j                  S t        ‰| �  S )za:returns: log directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   r?   rš   r=   r›   s    €r   r=   zUnix.user_log_dir  ó!   ø€ ð %)§N¢Nˆt× Ñ ÐL¼¹Ñ8LÐLr   c                óH   •— | j                   r| j                  S t        ‰| �  S )zj:returns: applications directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   rs   rš   rk   r›   s    €r   rk   zUnix.user_applications_dir  s!   ø€ ð .2¯^ª^ˆt×)Ñ)Ð^ÄÁÑA^Ð^r   c                óH   •— | j                   r| j                  S t        ‰| �  S )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}   zUnix.user_runtime_dir  s!   ø€ ð )-¯ªˆt×$Ñ$ÐT¼E¹GÑ<TÐTr   c                óH   •— | j                   r| j                  S t        ‰| �  S )za:returns: bin directory tied to the user, or site equivalent when root with ``use_site_for_root``)r   rh   rš   re   r›   s    €r   re   zUnix.user_bin_dir  r¢   r   r�   )r’   r“   r”   r•   r–   r#   r,   r0   r4   r=   rk   r}   re   Ú__classcell__)rœ   s   @r   r˜   r˜   î   s¸   ø„ ñð ôOó ðOð ôSó ðSð ôQó ðQð ôQó ðQð ôMó ðMð ô_ó ð_ð ôUó ðUð ôMó ôMr   r˜   c                ó^   — t        | «      x}r|S t        j                  j                  |«      S )N)Ú_get_user_dirs_folderr    r!   r"   )Úenv_varÚfallback_tilde_pathÚ	media_dirs      r   rC   rC   "  s.   € Ü)¨'Ó2Ð2€yÐ2ØÐÜ�7‰7×ÑÐ1Ó2Ð2r   c                ó  — t         j                  j                  dd«      j                  «       xs t         j                  j                  d«      }t        |«      dz  }|j                  «       r“t        «       }|j                  «       5 }|j                  d|j                  «       › �«       ddd«       | |d   vry|d   |    j                  d«      }|j                  d	t         j                  j                  d
«      «      S y# 1 sw Y   ŒXxY w)zvReturn 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÷	:ð �f˜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    rx   Úconfigparserr   Ú	functoolsr   Úpathlibr   Útempfiler   Útypingr   r	   Ú_xdgr   Úapir   Úcollections.abcr   ry   r   r   r˜   rC   r¨   Ú__all__rg   r   r   ú<module>rÉ      sx   ðÙ å "ã 	Û 
Ý %Ý %Ý Ý ß *å Ý  áÝ(à‡<�<�7Òô õ
 ôN(�Oô N(ôb1Mˆ8�]ô 1Móh3óð0 ð�r   