Your IP : 3.145.36.46
�
��bg='���dZddlmZddlZddlZddlmZddlmZddl m
Z
ejdkrdd�ZnddlmZGd
�de
��Z
dd�Zdd�ZdgZdS)zUnix.�)�annotationsN)�ConfigParser)�Path�)�PlatformDirsABC�win32�return�intc�$�d}t|���)Nzshould only be used on Unix)�RuntimeError)�msgs �H/opt/cloudlinux/venv/lib64/python3.11/site-packages/platformdirs/unix.py�getuidr
s��+���3����)rc���eZdZdZedd���Zedd���Zdd�Zedd���Zedd ���Z edd
���Z
edd���Zedd���Zedd
���Z
edd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zd d�ZdS)!�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>`.
r �strc���tj�dd��}|���stj�d��}|�|��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"sS���z�~�~�o�r�2�2���z�z�|�|� 8��7�%�%�&6�7�7�D��0�0��6�6�6rc��tj�dd��}|���sdtj�d�}|�|��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-sO���z�~�~�o�r�2�2���z�z�|�|� =�<�b�j�<�<�<�D��$�$�T�*�*�*rrc���|�tj��}�js
|dd�}�fd�|D��}tj�|��S)Nrrc�t��g|]4}��tj�|������5S�)rrrr)�.0�pr s �r�
<listcomp>z)Unix._with_multi_path.<locals>.<listcomp>>s8���a�a�a�RS�T�6�6�r�w�7I�7I�!�7L�7L�M�M�a�a�ar)�splitrr$� multipath�join)r r� path_lists` rr%zUnix._with_multi_path:s[����J�J�r�z�*�*� ��~� '�!�!�A�#��I�a�a�a�a�W`�a�a�a� ��z���y�)�)�)rc���tj�dd��}|���stj�d��}|�|��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_dirAsS���z�~�~�/��4�4���z�z�|�|� 3��7�%�%�k�2�2�D��0�0��6�6�6rc��tj�dd��}|���sd}|�|��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_dirLsC���z�~�~�/��4�4���z�z�|�|� ��D��$�$�T�*�*�*rc���tj�dd��}|���stj�d��}|�|��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_dirYsS���z�~�~�.��3�3���z�z�|�|� 2��7�%�%�j�1�1�D��0�0��6�6�6rc�,�|�d��S)zM:return: cache directory shared by users, e.g. ``/var/tmp/$appname/$version``z/var/tmp)r�r s r�site_cache_dirzUnix.site_cache_dirds���0�0��<�<�<rc���tj�dd��}|���stj�d��}|�|��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_dirisT���z�~�~�.��3�3���z�z�|�|� 8��7�%�%�&6�7�7�D��0�0��6�6�6rc��|j}|jr5tj�|d��}|�|��|S)zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it�log)r?�opinionrrr/�_optionally_create_directoryrs r�user_log_dirzUnix.user_log_dirtsD���"���<� 4��7�<�<��e�,�,�D��-�-�d�3�3�3��rc�"�tdd��S)zC:return: documents directory tied to the user, e.g. ``~/Documents``�XDG_DOCUMENTS_DIRz~/Documents��_get_user_media_dirr;s r�user_documents_dirzUnix.user_documents_dir}s��#�#6�
�F�F�Frc�"�tdd��S)zC:return: downloads directory tied to the user, e.g. ``~/Downloads``�XDG_DOWNLOAD_DIRz~/DownloadsrGr;s r�user_downloads_dirzUnix.user_downloads_dir�s��#�#5�}�E�E�Erc�"�tdd��S)zA:return: pictures directory tied to the user, e.g. ``~/Pictures``�XDG_PICTURES_DIRz
~/PicturesrGr;s r�user_pictures_dirzUnix.user_pictures_dir�s��#�#5�|�D�D�Drc�"�tdd��S)z=:return: videos directory tied to the user, e.g. ``~/Videos``�XDG_VIDEOS_DIRz~/VideosrGr;s 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~/MusicrGr;s r�user_music_dirzUnix.user_music_dir�s��#�?�I�>�>�>rc�"�tdd��S)z?:return: desktop directory tied to the user, e.g. ``~/Desktop``�XDG_DESKTOP_DIRz ~/DesktoprGr;s r�user_desktop_dirzUnix.user_desktop_dir�s��#�#4�k�B�B�Brc�|�tj�dd��}|���sttj�d��rDdt����}t|��� ��sdt����}ndt����}|�
|��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�
startswithrr�existsrrs r�user_runtime_dirzUnix.user_runtime_dir�s����z�~�~�/��4�4���z�z�|�|� /��|�&�&�'G�H�H�
/�2����2�2���D�z�z�(�(�*�*�6�5�6�8�8�5�5�D��.�F�H�H�.�.���0�0��6�6�6rc���tj�dd��}|���s$tj�d��rd}nd}|�|��S)am
:return: 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.
rZrr[z/var/runz/run)rrrrr_r`rarrs r�site_runtime_dirzUnix.site_runtime_dir�sc���z�~�~�/��4�4���z�z�|�|� ��|�&�&�'G�H�H�
�!������0�0��6�6�6rrc�6�|�|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&r;s r�site_data_pathzUnix.site_data_path�s���4�4�T�5G�H�H�Hrc�6�|�|j��S)zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)rgr6r;s r�site_config_pathzUnix.site_config_path�s���4�4�T�5I�J�J�Jrc�6�|�|j��S)ze:return: cache path shared by users. Only return first item, even if ``multipath`` is set to ``True``)rgr<r;s r�site_cache_pathzUnix.site_cache_path�s���4�4�T�5H�I�I�Ir� directoryc�x�|jr%|�tj��d}t |��S)Nr)r.r-rr$r)r rms rrgz%Unix._first_item_as_path_if_multipath�s0���>� 7�!����
�3�3�A�6�I��I���rN)r r)rrr r)r r)rmrr r)�__name__�
__module__�__qualname__�__doc__�propertyr!r&r%r3r6r9r<r?rDrIrLrOrRrUrXrcrerhrjrlrgr)rrrrs�������
�
��7�7�7��X�7��
+�
+�
+��X�
+�*�*�*�*��7�7�7��X�7��
+�
+�
+��X�
+��7�7�7��X�7��=�=�=��X�=��7�7�7��X�7������X���G�G�G��X�G��F�F�F��X�F��E�E�E��X�E��A�A�A��X�A��?�?�?��X�?��C�C�C��X�C��7�7�7��X�7�&�7�7�7��X�7�*�I�I�I��X�I��K�K�K��X�K��J�J�J��X�J������rr�env_varr�fallback_tilde_pathc���t|��}|�Stj�|d�����}|stj�|��}|S)Nr)�_get_user_dirs_folderrrrrrr)rtru� media_dirs rrHrH�s[��%�g�.�.�I����J�N�N�7�B�/�/�5�5�7�7� �� @���*�*�+>�?�?�I��r�key�
str | Nonec��tt��j��dz}|���r�t ��}|���5}|�d|�������ddd��n#1swxYwY||dvrdS|d|�d��}|� dtj�d����SdS)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�~)
rrr3rbr�open�read_string�readr�replacerrr)ry�user_dirs_config_path�parser�streamrs rrwrw�s�� ����!7�8�8�;K�K���#�#�%�%�>�����
"�
'�
'�
)�
)� :�V����8������8�8�9�9�9� :� :� :� :� :� :� :� :� :� :� :���� :� :� :� :��f�U�m�#�#��4��e�}�S�!�'�'��,�,���|�|�G�R�W�%7�%7��%<�%<�=�=�=��4s�+B�B�B)r r
)rtrrurr r)ryrr rz)rr�
__future__rrr_�configparserr�pathlibr�apirr`rrrHrw�__all__r)rr�<module>r�s ����"�"�"�"�"�"� � � � �
�
�
�
�%�%�%�%�%�%������� � � � � � ��<�7��� � � � � �
������C�C�C�C�C�?�C�C�C�L��������*����r
?>