Current File : //usr/lib/python3/dist-packages/pip/_vendor/platformdirs/__pycache__/unix.cpython-312.pyc
�

/�gi"���dZddlmZddlZddlZddlmZddlmZddl	m
Z
ejdk(rdd	�Zndd
lmZGd�de
�Z
dd
�Zdd�ZdgZy)zUnix.�)�annotationsN)�ConfigParser)�Path�)�PlatformDirsABC�win32c��d}t|��)Nzshould only be used on Unix)�RuntimeError)�msgs �?/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/unix.py�getuidr

s��+���3���)r
c�R�eZdZdZedd��Zedd��Zdd�Zedd��Zedd��Z	edd��Z
edd��Zedd	��Zedd
��Z
edd��Zedd��Zedd
��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zdd�Zy)�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���tjjdd�}|j�stjjd�}|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��selfrs  r�
user_data_dirzUnix.user_data_dir"sG���z�z�~�~�o�r�2���z�z�|��7�7�%�%�&6�7�D��0�0��6�6rc��tjjdd�}|j�sdtj�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_DIRSrz/usr/local/sharez
/usr/share)rrrr�pathsep�_with_multi_pathrs  r�
site_data_dirzUnix.site_data_dir-sD���z�z�~�~�o�r�2���z�z�|�%�b�j�j�\��<�D��$�$�T�*�*rc� �|jtj�}|js|dd}|D�cgc]0}|j	tj
j
|����2}}tjj|�Scc}w)Nrr)�splitrr!�	multipathrrr�join)rr�	path_list�ps    rr"zUnix._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�)�)��bs�5Bc���tjjdd�}|j�stjjd�}|j
|�S)z�
        :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or
         ``$XDG_CONFIG_HOME/$appname/$version``
        �XDG_CONFIG_HOMErz	~/.configrrs  r�user_config_dirzUnix.user_config_dirAsG���z�z�~�~�/��4���z�z�|��7�7�%�%�k�2�D��0�0��6�6rc��tjjdd�}|j�sd}|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_DIRSrz/etc/xdg)rrrrr"rs  r�site_config_dirzUnix.site_config_dirLs8���z�z�~�~�/��4���z�z�|��D��$�$�T�*�*rc���tjjdd�}|j�stjjd�}|j
|�S)z�
        :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or
         ``~/$XDG_CACHE_HOME/$appname/$version``
        �XDG_CACHE_HOMErz~/.cacherrs  r�user_cache_dirzUnix.user_cache_dirYsG���z�z�~�~�.��3���z�z�|��7�7�%�%�j�1�D��0�0��6�6rc�$�|jd�S)zM:return: cache directory shared by users, e.g. ``/var/tmp/$appname/$version``z/var/tmp)r�rs r�site_cache_dirzUnix.site_cache_dirds���0�0��<�<rc���tjjdd�}|j�stjjd�}|j
|�S)z�
        :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or
         ``$XDG_STATE_HOME/$appname/$version``
        �XDG_STATE_HOMErz~/.local/staterrs  r�user_state_dirzUnix.user_state_dirisH���z�z�~�~�.��3���z�z�|��7�7�%�%�&6�7�D��0�0��6�6rc�v�|j}|jr tjj	|d�}|S)zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it�log)r8�opinionrrr'rs  r�user_log_dirzUnix.user_log_dirts/���"�"���<�<��7�7�<�<��e�,�D��rc��tdd�S)zC:return: documents directory tied to the user, e.g. ``~/Documents``�XDG_DOCUMENTS_DIRz~/Documents��_get_user_media_dirr4s r�user_documents_dirzUnix.user_documents_dir|s��#�#6�
�F�Frc��tdd�S)zC:return: downloads directory tied to the user, e.g. ``~/Downloads``�XDG_DOWNLOAD_DIRz~/Downloadsr?r4s r�user_downloads_dirzUnix.user_downloads_dir�s��#�#5�}�E�Erc��tdd�S)zA:return: pictures directory tied to the user, e.g. ``~/Pictures``�XDG_PICTURES_DIRz
~/Picturesr?r4s r�user_pictures_dirzUnix.user_pictures_dir�s��#�#5�|�D�Drc��tdd�S)z=:return: videos directory tied to the user, e.g. ``~/Videos``�XDG_VIDEOS_DIRz~/Videosr?r4s r�user_videos_dirzUnix.user_videos_dir�s��#�#3�Z�@�@rc��tdd�S)z;:return: music directory tied to the user, e.g. ``~/Music``�
XDG_MUSIC_DIRz~/Musicr?r4s r�user_music_dirzUnix.user_music_dir�s��#�?�I�>�>rc�D�tjjdd�}|j�s`tj
j
d�r4dt���}t|�j�sdt���}n
dt���}|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/)rrrr�sys�platform�
startswithr
r�existsrrs  r�user_runtime_dirzUnix.user_runtime_dir�s����z�z�~�~�/��4���z�z�|��|�|�&�&�'G�H�'���z�2���D�z�(�(�*�*�6�8�*�5�D�#�F�H�:�.���0�0��6�6rc�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#r4s r�site_data_pathzUnix.site_data_path�s���4�4�T�5G�5G�H�Hrc�8�|j|j�S)zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)rYr/r4s r�site_config_pathzUnix.site_config_path�s���4�4�T�5I�5I�J�Jrc�8�|j|j�S)ze:return: cache path shared by users. Only return first item, even if ``multipath`` is set to ``True``)rYr5r4s r�site_cache_pathzUnix.site_cache_path�s���4�4�T�5H�5H�I�Irc�t�|jr"|jtj�d}t	|�S)Nr)r&r%rr!r)r�	directorys  rrYz%Unix._first_item_as_path_if_multipath�s*���>�>�!����
�
�3�A�6�I��I��rN)�return�str)rrbrarb)rar)r`rbrar)�__name__�
__module__�__qualname__�__doc__�propertyrr#r"r,r/r2r5r8r<rArDrGrJrMrWrZr\r^rY�rrrrss��
��7��7��
+��
+�*��7��7��
+��
+��7��7��=��=��7��7������G��G��F��F��E��E��A��A��?��?��7��7�&�I��I��K��K��J��J�rrc��t|�}|�Otjj|d�j	�}|stj
j
|�}|S)Nr)�_get_user_dirs_folderrrrrrr)�env_var�fallback_tilde_path�	media_dirs   rr@r@�sM��%�g�.�I����J�J�N�N�7�B�/�5�5�7�	�����*�*�+>�?�I��rc��tt�j�dz}|j�r�t	�}|j�5}|j
d|j����ddd�||dvry|d|jd�}|jdtjjd��Sy#1swY�XxYw)zkReturn directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/.zuser-dirs.dirsz[top]
N�top�"z$HOME�~)
rrr,rVr�open�read_string�readr�replacerrr)�key�user_dirs_config_path�parser�streamrs     rrjrj�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)rkrbrlrbrarb)rvrbraz
str | None)rf�
__future__rrrS�configparserr�pathlibr�apirrTr
rr@rj�__all__rhrr�<module>r�sU���"�	�
�%�� ��<�<�7�� �
�g�?�g�T��*��r