Ë
    äØjji"  ã                  ó¨   — 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
 ej                  dk(  rdd	„Zndd
lmZ  G d„ de
«      Zdd„Zdd„ZdgZy)zUnix.é    )ÚannotationsN)ÚConfigParser)ÚPathé   )ÚPlatformDirsABCÚwin32c                 ó   — d} t        | «      ‚)Nzshould only be used on Unix)ÚRuntimeError)Úmsgs    ú_/opt/eval-harness/bench_task/venv/lib/python3.12/site-packages/pip/_vendor/platformdirs/unix.pyÚgetuidr      s   € Ø+ˆÜ˜3ÓÐó    )r   c                  óR  — e Zd ZdZedd„«       Zedd„«       Z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y)ÚUnixaŠ  
    On Unix/Linux, we follow the
    `XDG Basedir Spec <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_. The spec allows
    overriding directories with environment variables. The examples show 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                óÂ   — t         j                  j                  dd«      }|j                  «       st         j                  j                  d«      }| j                  |«      S )z–
        :return: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or
         ``$XDG_DATA_HOME/$appname/$version``
        ÚXDG_DATA_HOMEÚ z~/.local/share©ÚosÚenvironÚgetÚstripÚpathÚ
expanduserÚ_append_app_name_and_version©Úselfr   s     r   Úuser_data_dirzUnix.user_data_dir"   sG   € ô �z‰z�~‰~˜o¨rÓ2ˆØ�z‰zŒ|Ü—7‘7×%Ñ%Ð&6Ó7ˆDØ×0Ñ0°Ó6Ð6r   c                ó¬   — t         j                  j                  dd«      }|j                  «       sdt         j                  › d�}| j                  |«      S )aY  
        :return: data directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is
         enabled and ``XDG_DATA_DIR`` is set and a multi path the response is also a multi path separated by the OS
         path separator), e.g. ``/usr/local/share/$appname/$version`` or ``/usr/share/$appname/$version``
        ÚXDG_DATA_DIRSr   z/usr/local/sharez
/usr/share)r   r   r   r   ÚpathsepÚ_with_multi_pathr   s     r   Úsite_data_dirzUnix.site_data_dir-   sD   € ô �z‰z�~‰~˜o¨rÓ2ˆØ�z‰zŒ|Ø%¤b§j¡j \°Ð<ˆDØ×$Ñ$ TÓ*Ð*r   c                ó   — |j                  t        j                  «      }| j                  s|dd }|D �cg c]0  }| j	                  t        j
                  j                  |«      «      ‘Œ2 }}t        j                  j                  |«      S c c}w )Nr   r   )Úsplitr   r!   Ú	multipathr   r   r   Újoin)r   r   Ú	path_listÚps       r   r"   zUnix._with_multi_path:   sm   € Ø—J‘JœrŸz™zÓ*ˆ	Ø�~Š~Ø! ! A˜ˆIØW`ÖaÐRS�T×6Ñ6´r·w±w×7IÑ7IÈ!Ó7LÕMÐaˆ	ÐaÜ�z‰z�‰˜yÓ)Ð)ùò bs   µ5Bc                óÂ   — t         j                  j                  dd«      }|j                  «       st         j                  j                  d«      }| j                  |«      S )z•
        :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or
         ``$XDG_CONFIG_HOME/$appname/$version``
        ÚXDG_CONFIG_HOMEr   z	~/.configr   r   s     r   Úuser_config_dirzUnix.user_config_dirA   sG   € ô �z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|Ü—7‘7×%Ñ% kÓ2ˆDØ×0Ñ0°Ó6Ð6r   c                óˆ   — t         j                  j                  dd«      }|j                  «       sd}| j	                  |«      S )a/  
        :return: config directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>`
         is enabled and ``XDG_DATA_DIR`` is set and a multi path the response is also a multi path separated by the OS
         path separator), e.g. ``/etc/xdg/$appname/$version``
        ÚXDG_CONFIG_DIRSr   z/etc/xdg)r   r   r   r   r"   r   s     r   Úsite_config_dirzUnix.site_config_dirL   s8   € ô �z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|ØˆDØ×$Ñ$ TÓ*Ð*r   c                óÂ   — t         j                  j                  dd«      }|j                  «       st         j                  j                  d«      }| j                  |«      S )z”
        :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or
         ``~/$XDG_CACHE_HOME/$appname/$version``
        ÚXDG_CACHE_HOMEr   z~/.cacher   r   s     r   Úuser_cache_dirzUnix.user_cache_dirY   sG   € ô �z‰z�~‰~Ð.°Ó3ˆØ�z‰zŒ|Ü—7‘7×%Ñ% jÓ1ˆDØ×0Ñ0°Ó6Ð6r   c                ó$   — | j                  d«      S )zM:return: cache directory shared by users, e.g. ``/var/tmp/$appname/$version``z/var/tmp)r   ©r   s    r   Úsite_cache_dirzUnix.site_cache_dird   s   € ð ×0Ñ0°Ó<Ð<r   c                óÂ   — t         j                  j                  dd«      }|j                  «       st         j                  j                  d«      }| j                  |«      S )z˜
        :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or
         ``$XDG_STATE_HOME/$appname/$version``
        ÚXDG_STATE_HOMEr   z~/.local/stater   r   s     r   Úuser_state_dirzUnix.user_state_diri   sH   € ô �z‰z�~‰~Ð.°Ó3ˆØ�z‰zŒ|Ü—7‘7×%Ñ%Ð&6Ó7ˆDØ×0Ñ0°Ó6Ð6r   c                óv   — | j                   }| j                  r t        j                  j	                  |d«      }|S )zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itÚlog)r8   Úopinionr   r   r'   r   s     r   Úuser_log_dirzUnix.user_log_dirt   s/   € ð ×"Ñ"ˆØ�<Š<Ü—7‘7—<‘<  eÓ,ˆDØˆr   c                ó   — t        dd«      S )zC:return: documents directory tied to the user, e.g. ``~/Documents``ÚXDG_DOCUMENTS_DIRz~/Documents©Ú_get_user_media_dirr4   s    r   Úuser_documents_dirzUnix.user_documents_dir|   s   € ô #Ð#6¸ÓFÐFr   c                ó   — t        dd«      S )zC:return: downloads directory tied to the user, e.g. ``~/Downloads``ÚXDG_DOWNLOAD_DIRz~/Downloadsr?   r4   s    r   Úuser_downloads_dirzUnix.user_downloads_dir�   s   € ô #Ð#5°}ÓEÐEr   c                ó   — t        dd«      S )zA:return: pictures directory tied to the user, e.g. ``~/Pictures``ÚXDG_PICTURES_DIRz
~/Picturesr?   r4   s    r   Úuser_pictures_dirzUnix.user_pictures_dir†   s   € ô #Ð#5°|ÓDÐDr   c                ó   — t        dd«      S )z=:return: videos directory tied to the user, e.g. ``~/Videos``ÚXDG_VIDEOS_DIRz~/Videosr?   r4   s    r   Úuser_videos_dirzUnix.user_videos_dir‹   s   € ô #Ð#3°ZÓ@Ð@r   c                ó   — t        dd«      S )z;:return: music directory tied to the user, e.g. ``~/Music``ÚXDG_MUSIC_DIRz~/Musicr?   r4   s    r   Úuser_music_dirzUnix.user_music_dir�   s   € ô # ?°IÓ>Ð>r   c                óD  — t         j                  j                  dd«      }|j                  «       s`t        j
                  j                  d«      r4dt        «       › �}t        |«      j                  «       sdt        «       › �}ndt        «       › �}| j                  |«      S )az  
        :return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or
         ``$XDG_RUNTIME_DIR/$appname/$version``.

         For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/user/$(id -u)/$appname/$version`` if
         exists, otherwise ``/tmp/runtime-$(id -u)/$appname/$version``, if``$XDG_RUNTIME_DIR``
         is not set.
        ÚXDG_RUNTIME_DIRr   )ÚfreebsdÚopenbsdÚnetbsdz/var/run/user/z/tmp/runtime-z
/run/user/)r   r   r   r   ÚsysÚplatformÚ
startswithr   r   Úexistsr   r   s     r   Úuser_runtime_dirzUnix.user_runtime_dir•   s€   € ô �z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|Ü�|‰|×&Ñ&Ð'GÔHØ'¬« zÐ2�Ü˜D“z×(Ñ(Ô*Ø*¬6«8¨*Ð5‘Dà#¤F£H :Ð.�Ø×0Ñ0°Ó6Ð6r   c                ó8   — | j                  | j                  «      S )zd:return: data path shared by users. Only return first item, even if ``multipath`` is set to ``True``)Ú _first_item_as_path_if_multipathr#   r4   s    r   Úsite_data_pathzUnix.site_data_path©   s   € ð ×4Ñ4°T×5GÑ5GÓHÐHr   c                ó8   — | j                  | j                  «      S )zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)rY   r/   r4   s    r   Úsite_config_pathzUnix.site_config_path®   s   € ð ×4Ñ4°T×5IÑ5IÓJÐJr   c                ó8   — | j                  | j                  «      S )ze:return: cache path shared by users. Only return first item, even if ``multipath`` is set to ``True``)rY   r5   r4   s    r   Úsite_cache_pathzUnix.site_cache_path³   s   € ð ×4Ñ4°T×5HÑ5HÓIÐIr   c                ót   — | j                   r"|j                  t        j                  «      d   }t	        |«      S )Nr   )r&   r%   r   r!   r   )r   Ú	directorys     r   rY   z%Unix._first_item_as_path_if_multipath¸   s*   € Ø�>Š>à!Ÿ™¬¯
©
Ó3°AÑ6ˆIÜ�I‹Ðr   N)ÚreturnÚstr)r   rb   ra   rb   )ra   r   )r`   rb   ra   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r#   r"   r,   r/   r2   r5   r8   r<   rA   rD   rG   rJ   rM   rW   rZ   r\   r^   rY   © r   r   r   r      ss  „ ñ
ð ò7ó ð7ð ò
+ó ð
+ó*ð ò7ó ð7ð ò
+ó ð
+ð ò7ó ð7ð ò=ó ð=ð ò7ó ð7ð òó ðð òGó ðGð òFó ðFð òEó ðEð òAó ðAð ò?ó ð?ð ò7ó ð7ð& òIó ðIð òKó ðKð òJó ðJôr   r   c                ó¾   — t        | «      }|€Ot        j                  j                  | d«      j	                  «       }|st        j
                  j                  |«      }|S )Nr   )Ú_get_user_dirs_folderr   r   r   r   r   r   )Úenv_varÚfallback_tilde_pathÚ	media_dirs      r   r@   r@   ¿   sM   € Ü% gÓ.€IØÐÜ—J‘J—N‘N 7¨BÓ/×5Ñ5Ó7ˆ	ÙÜŸ™×*Ñ*Ð+>Ó?ˆIàÐr   c                ó¢  — t        t        «       j                  «      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)zkReturn directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/.zuser-dirs.dirsz[top]
NÚtopú"z$HOMEú~)r   r   r,   rV   r   ÚopenÚread_stringÚreadr   Úreplacer   r   r   )ÚkeyÚuser_dirs_config_pathÚparserÚstreamr   s        r   rj   rj   É   s¹   € ä ¤£×!7Ñ!7Ó8Ð;KÑKÐØ×#Ñ#Ô%Ü“ˆà"×'Ñ'Ó)ð 	:¨Và×Ñ ¨¯©«¨Ð8Ô9÷	:ð �f˜U‘mÑ#Øà�e‰}˜SÑ!×'Ñ'¨Ó,ˆà�|‰|˜G¤R§W¡W×%7Ñ%7¸Ó%<Ó=Ð=à÷	:ð 	:ús   Á#CÃC)ra   Úint)rk   rb   rl   rb   ra   rb   )rv   rb   ra   z
str | None)rf   Ú
__future__r   r   rS   Úconfigparserr   Úpathlibr   Úapir   rT   r   r   r@   rj   Ú__all__rh   r   r   ú<module>r€      sU   ðÙ Ý "ã 	Û 
Ý %Ý å  à‡<�<�7Òô õ
 ôgˆ?ô góTóð* ð�r   