� u��g�(����dZddlmZddlZddlZddlmZddlmZddl m Z m Z ddl m Z e rdd lmZejd krdd �ZnddlmZGd�de ��Zdd�Zdd�ZdgZdS)zUnix.�)� annotationsN)� ConfigParser)�Path)� TYPE_CHECKING�NoReturn�)�PlatformDirsABC)�Iterator�win32�returnrc�$�d}t|���)Nzshould only be used on Unix)� RuntimeError)�msgs �a/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/platformdirs/unix.py�getuidrs��+���3����)rc��eZdZdZedd���Zed d���Zedd���Zedd���Zed d ���Z edd ���Z edd ���Z edd ���Z edd ���Z edd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zedd���Zed!d���Zed!d���Zed!d���Zd"d�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 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>`. 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�6r� list[str]c����tj�dd��}|���sdtj�d�}�fd�|�tj��D��S)N� XDG_DATA_DIRSrz/usr/local/sharez /usr/sharec�:��g|]}��|����S��r ��.0�pr"s �r� <listcomp>z(Unix._site_data_dirs.<locals>.<listcomp>7�'���U�U�U���1�1�!�4�4�U�U�Ur)rrrr�pathsep�splitr!s` r�_site_data_dirszUnix._site_data_dirs2sb����z�~�~�o�r�2�2���z�z�|�|� =�<�b�j�<�<�<�D�U�U�U�U�d�j�j���>T�>T�U�U�U�Urc�l�|j}|js|dStj�|��S)aZ :return: data directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled and ``XDG_DATA_DIRS`` 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`` r)r1� multipathrr/�join�r"�dirss r� site_data_dirzUnix.site_data_dir9s3���#���~� ���7�N��z���t�$�$�$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 ~/.configrr!s r�user_config_dirzUnix.user_config_dirFsS�� �z�~�~�/��4�4���z�z�|�|� 3��7�%�%�k�2�2�D��0�0��6�6�6rc����tj�dd��}|���sd}�fd�|�tj��D��S)N�XDG_CONFIG_DIRSrz/etc/xdgc�:��g|]}��|����Sr(r)r*s �rr-z*Unix._site_config_dirs.<locals>.<listcomp>Vr.r)rrrrr0r/r!s` r�_site_config_dirszUnix._site_config_dirsQsV����z�~�~�/��4�4���z�z�|�|� ��D�U�U�U�U�d�j�j���>T�>T�U�U�U�Urc�l�|j}|js|dStj�|��S)a2 :return: config directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled and ``XDG_CONFIG_DIRS`` 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`` r)r>r3rr/r4r5s r�site_config_dirzUnix.site_config_dirXs3���%���~� ���7�N��z���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~/.cacherr!s r�user_cache_dirzUnix.user_cache_diresS�� �z�~�~�.��3�3���z�z�|�|� 2��7�%�%�j�1�1�D��0�0��6�6�6rc�,�|�d��S)zO:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z /var/cacher)�r"s r�site_cache_dirzUnix.site_cache_dirps���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/staterr!s r�user_state_dirzUnix.user_state_dirusT�� �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)rI�opinionrrr4�_optionally_create_directoryr!s r� user_log_dirzUnix.user_log_dir�sD���"�� �<� 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_dirrEs 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 ~/DownloadsrQrEs 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 ~/PicturesrQrEs 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~/VideosrQrEs 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~/MusicrQrEs 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 ~/DesktoprQrEs 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�existsr r!s 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. rdrrez/var/runz/run)rrrrrirjrkr r!s r�site_runtime_dirzUnix.site_runtime_dir�sc���z�~�~�/��4�4���z�z�|�|� ��|�&�&�'G�H�H� �!������0�0��6�6�6rrc�6�|�|j��S)zh:return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)� _first_item_as_path_if_multipathr7rEs 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, returns the first item, even if ``multipath`` is set to ``True``)rqr@rEs r�site_config_pathzUnix.site_config_path�s���4�4�T�5I�J�J�Jrc�6�|�|j��S)zi:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)rqrFrEs r�site_cache_pathzUnix.site_cache_path�s���4�4�T�5H�I�I�Ir� Iterator[str]c#�6K�|jV�|jEd{V��dS)z4:yield: all user and site configuration directories.N)r:r>rEs r�iter_config_dirszUnix.iter_config_dirs�s6�����"�"�"�"��)�)�)�)�)�)�)�)�)�)rc#�6K�|jV�|jEd{V��dS)z+:yield: all user and site data directories.N)r#r1rEs r�iter_data_dirszUnix.iter_data_dirs�s6����� � � � ��'�'�'�'�'�'�'�'�'�'rN)r r)r r$)r r)r rw)�__name__� __module__� __qualname__�__doc__�propertyr#r1r7r:r>r@rCrFrIrNrSrVrYr\r_rbrmrorrrtrvryr{r(rrrrs������ � ��7�7�7��X�7��V�V�V��X�V� � %� %� %��X� %��7�7�7��X�7��V�V�V��X�V� � %� %� %��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)r�r�� media_dirs rrRrR�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)z{ Return 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:rlr�open� read_string�readr�replacerrr)r��user_dirs_config_path�parser�streamrs rr�r��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)r�rr�rr r)r�rr r�)r� __future__rrri� configparserr�pathlibr�typingrr�apir �collections.abcr rjrrrRr��__all__r(rr�<module>r�s;�� � �"�"�"�"�"�"� � � � � � � � �%�%�%�%�%�%�������*�*�*�*�*�*�*�*� � � � � � ��)�(�(�(�(�(�(��<�7��� � � � � � ������N(�N(�N(�N(�N(�?�N(�N(�N(�b��������4 � ���r
Memory