
    Mh(                        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
mZ ddlmZ e
r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dS )zUnix.    )annotationsN)ConfigParser)Path)TYPE_CHECKINGNoReturn   )PlatformDirsABC)Iteratorwin32returnr   c                 $    d} t          |           )Nzshould only be used on Unix)RuntimeError)msgs    Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/platformdirs/unix.pygetuidr      s    +3    )r   c                     e Zd Z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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d"dZdS )#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                    t           j                            dd          }|                                st           j                            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selfr   s     r   user_data_dirzUnix.user_data_dir'   sS     z~~or22zz|| 	87%%&677D00666r   	list[str]c                     t           j                            dd          }|                                sdt           j         d} fd|                    t           j                  D             S )NXDG_DATA_DIRSr   z/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   )r   r   r   r   pathsepsplitr!   s   ` r   _site_data_dirszUnix._site_data_dirs2   sb    z~~or22zz|| 	=<bj<<<DUUUUdjj>T>TUUUUr   c                l    | j         }| j        s|d         S t          j                            |          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   	multipathr   r/   joinr"   dirss     r   site_data_dirzUnix.site_data_dir9   s3     #~ 	7Nzt$$$r   c                    t           j                            dd          }|                                st           j                            d          }|                     |          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_dirF   sS     z~~/44zz|| 	37%%k22D00666r   c                     t           j                            dd          }|                                sd} fd|                    t           j                  D             S )NXDG_CONFIG_DIRSr   z/etc/xdgc                :    g | ]}                     |          S r(   r)   r*   s     r   r-   z*Unix._site_config_dirs.<locals>.<listcomp>V   r.   r   )r   r   r   r   r0   r/   r!   s   ` r   _site_config_dirszUnix._site_config_dirsQ   sV    z~~/44zz|| 	DUUUUdjj>T>TUUUUr   c                l    | j         }| j        s|d         S t          j                            |          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>   r3   r   r/   r4   r5   s     r   site_config_dirzUnix.site_config_dirX   s3     %~ 	7Nzt$$$r   c                    t           j                            dd          }|                                st           j                            d          }|                     |          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_dire   sS     z~~.33zz|| 	27%%j11D00666r   c                ,    |                      d          S )zO:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z
/var/cacher)   r"   s    r   site_cache_dirzUnix.site_cache_dirp   s     00>>>r   c                    t           j                            dd          }|                                st           j                            d          }|                     |          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_diru   sT     z~~.33zz|| 	87%%&677D00666r   c                    | j         }| j        r5t          j                            |d          }|                     |           |S )zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itlog)rI   opinionr   r   r4   _optionally_create_directoryr!   s     r   user_log_dirzUnix.user_log_dir   sD     "< 	47<<e,,D--d333r   c                "    t          dd          S )zC:return: documents directory tied to the user, e.g. ``~/Documents``XDG_DOCUMENTS_DIRz~/Documents_get_user_media_dirrE   s    r   user_documents_dirzUnix.user_documents_dir   s     ##6FFFr   c                "    t          dd          S )zC:return: downloads directory tied to the user, e.g. ``~/Downloads``XDG_DOWNLOAD_DIRz~/DownloadsrQ   rE   s    r   user_downloads_dirzUnix.user_downloads_dir   s     ##5}EEEr   c                "    t          dd          S )zA:return: pictures directory tied to the user, e.g. ``~/Pictures``XDG_PICTURES_DIRz
~/PicturesrQ   rE   s    r   user_pictures_dirzUnix.user_pictures_dir   s     ##5|DDDr   c                "    t          dd          S )z=:return: videos directory tied to the user, e.g. ``~/Videos``XDG_VIDEOS_DIRz~/VideosrQ   rE   s    r   user_videos_dirzUnix.user_videos_dir   s     ##3Z@@@r   c                "    t          dd          S )z;:return: music directory tied to the user, e.g. ``~/Music``XDG_MUSIC_DIRz~/MusicrQ   rE   s    r   user_music_dirzUnix.user_music_dir   s     #?I>>>r   c                "    t          dd          S )z?:return: desktop directory tied to the user, e.g. ``~/Desktop``XDG_DESKTOP_DIRz	~/DesktoprQ   rE   s    r   user_desktop_dirzUnix.user_desktop_dir   s     ##4kBBBr   c                |   t           j                            dd          }|                                stt          j                            d          rDdt                       }t          |          	                                sdt                       }ndt                       }| 
                    |          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~~/44zz|| 	/|&&'GHH /222Dzz((** 6568855D.FHH..00666r   c                    t           j                            dd          }|                                s$t          j                            d          rd}nd}|                     |          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.
        rd   r   re   z/var/runz/run)r   r   r   r   ri   rj   rk   r    r!   s     r   site_runtime_dirzUnix.site_runtime_dir   sc     z~~/44zz|| 	|&&'GHH !00666r   r   c                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_multipathr7   rE   s    r   site_data_pathzUnix.site_data_path   s     44T5GHHHr   c                6    |                      | j                  S )zj:return: config path shared by the users, returns the first item, even if ``multipath`` is set to ``True``)rq   r@   rE   s    r   site_config_pathzUnix.site_config_path   s     44T5IJJJr   c                6    |                      | j                  S )zi:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)rq   rF   rE   s    r   site_cache_pathzUnix.site_cache_path   s     44T5HIIIr   Iterator[str]c              #  6   K   | j         V  | j        E d{V  dS )z4:yield: all user and site configuration directories.N)r:   r>   rE   s    r   iter_config_dirszUnix.iter_config_dirs   s6      """"))))))))))r   c              #  6   K   | j         V  | j        E d{V  dS )z+:yield: all user and site data directories.N)r#   r1   rE   s    r   iter_data_dirszUnix.iter_data_dirs   s6          ''''''''''r   N)r   r   )r   r$   )r   r   )r   rw   )__name__
__module____qualname____doc__propertyr#   r1   r7   r:   r>   r@   rC   rF   rI   rN   rS   rV   rY   r\   r_   rb   rm   ro   rr   rt   rv   ry   r{   r(   r   r   r   r      s       
 
 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* * * *
( ( ( ( ( (r   r   env_varr   fallback_tilde_pathc                    t          |           }|St          j                            | d                                          }|st          j                            |          }|S )Nr   )_get_user_dirs_folderr   r   r   r   r   r   )r   r   	media_dirs      r   rR   rR      s[    %g..IJNN7B//5577	 	@**+>??Ir   key
str | Nonec                   t          t                      j                  dz  }|                                rt	                      }|                                5 }|                    d|                                            ddd           n# 1 swxY w Y   | |d         vrdS |d         |                              d          }|	                    dt          j                            d                    S dS )z{
    Return 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:   rl   r   openread_stringreadr   replacer   r   r   )r   user_dirs_config_pathparserstreamr   s        r   r   r      s     !!788;KK##%% >"'')) 	:V888999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: fUm##4e}S!'',,||GRW%7%7%<%<===4s   +BBB)r   r   )r   r   r   r   r   r   )r   r   r   r   )r   
__future__r   r   ri   configparserr   pathlibr   typingr   r   apir	   collections.abcr
   rj   r   r   rR   r   __all__r(   r   r   <module>r      s;    " " " " " " 				 



 % % % % % %       * * * * * * * *             )((((((<7         
 N( N( N( N( N(? N( N( N(b      4 r   