� ��^i�����ddlZddlZddlmZddlmZddlmZddlm Z ej � d��rddlm Z nd e fd �Z Gd �d e ��Zd ed eefd�Zd gZdS)�N)� ConfigParser)�Path)�Optional�)�PlatformDirsABC�linux)�getuid�returnc� �td���)Nzshould only be used on Linux)� RuntimeError����/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/platformdirs/unix.pyr r s���9�:�:�:rc�f�eZdZdZedefd���Zedefd���Zdedefd�Zedefd���Z edefd���Z edefd ���Z edefd ���Z edefd ���Z edefd ���Zedefd ���Zedefd���Zedefd���Zdedefd�ZdS)�UnixaD On Unix/Linux, we follow the `XDG Basedir Spec `_. 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 `, `version `, `multipath `, `opinion `. r c���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_dirsS�� �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 ` 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�|������5Sr )rrrr)�.0�prs �r� z)Unix._with_multi_path..9s8���a�a�a�RS�T�6�6�r�w�7I�7I�!�7L�7L�M�M�a�a�ar)�splitrr"� multipath�join)rr� path_lists` rr#zUnix._with_multi_path5s[����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_dir<sS�� �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 ` 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_dirGsC���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_dirTsS�� �z�~�~�.��3�3���z�z�|�|� 2��7�%�%�j�1�1�D��0�0��6�6�6rc���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_dir_sT�� �z�~�~�.��3�3���z�z�|�|� 8��7�%�%�&6�7�7�D��0�0��6�6�6rc�b�|j}|jr tj�|d��}|S)zx :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it �log)r6�opinionrrr,rs r� user_log_dirzUnix.user_log_dirjs0�� �"�� �<� -��7�<�<��e�,�,�D�� rc���td��}|�Stj�dd�����}|stj�d��}|S)zU :return: documents directory tied to the user, e.g. ``~/Documents`` �XDG_DOCUMENTS_DIRNrz ~/Documents)�_get_user_dirs_folderrrrrrr)r� documents_dirs r�user_documents_dirzUnix.user_documents_dirts^�� .�.A�B�B� � � ��J�N�N�+>��C�C�I�I�K�K�M� � B� "�� 2� 2�=� A� A� ��rc��tj�dd��}|���sdt ����}|�|��S)z� :return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or ``$XDG_RUNTIME_DIR/$appname/$version`` �XDG_RUNTIME_DIRrz /run/user/)rrrrr rrs r�user_runtime_dirzUnix.user_runtime_dir�sO�� �z�~�~�/��4�4���z�z�|�|� +�*����*�*�D��0�0��6�6�6rc�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$�rs 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``)rGr3rHs r�site_config_pathzUnix.site_config_path�s���4�4�T�5I�J�J�Jr� directoryc�x�|jr%|�tj��d}t |��S)Nr)r+r*rr"r)rrLs rrGz%Unix._first_item_as_path_if_multipath�s0�� �>� 7�!���� �3�3�A�6�I��I���rN)�__name__� __module__� __qualname__�__doc__�property�strrr$r#r0r3r6r9r=rBrErrIrKrGr rrrrs������ � ��7�s�7�7�7��X�7�� +�s� +� +� +��X� +�*�S�*�S�*�*�*�*��7��7�7�7��X�7�� +�� +� +� +��X� +��7��7�7�7��X�7��7��7�7�7��X�7���c�����X��� �C� � � ��X� ��7�#�7�7�7��X�7��I��I�I�I��X�I��K�$�K�K�K��X�K��#��$������rr�keyc�(�tj�t��jd��}tj�|��r�t ��}t|��5}|�d|� ������ddd��n #1swxYwY||dvrdS|d|� d��}|� dtj� d����}|SdS)zjReturn 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,rr0�existsr�open� read_string�readr�replacer)rT�user_dirs_config_path�parser�streamrs rr@r@�s%���G�L�L����)?�AQ�R�R�� �w�~�~�+�,�,� ����� �'� (� (� :�F� � � �8������8�8� 9� 9� 9� :� :� :� :� :� :� :� :� :� :� :���� :� :� :� :� �f�U�m� #� #��4��e�}�S�!�'�'��,�,���|�|�G�R�W�%7�%7��%<�%<�=�=��� � �4s�.+B%�%B)�,B))r�sys� configparserr�pathlibr�typingr�apir�platform� startswithr �intrrSr@�__all__r rr�rjs�� � � � � � � � �%�%�%�%�%�%������������� � � � � � ��<���7�#�#�;��������;�C�;�;�;�;�I�I�I�I�I�?�I�I�I�X�s��x��}�����, � ���r