o
    ⹏i                      @  s   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
 ddlmZmZ dd	lmZ dd
lmZ er>ddlmZ ejdkrIdddZnddlmZ G dd deZG dd deeZd ddZd!ddZdgZdS )"zUnix.    )annotationsN)ConfigParser)Path)
gettempdir)TYPE_CHECKINGNoReturn   )XDGMixin)PlatformDirsABC)Iteratorwin32returnr   c                  C  s   d} t | )Nzshould only be used on Unix)RuntimeError)msg r   N/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/platformdirs/unix.pygetuid   s   r   )r   c                   @  s.  e Zd ZdZed2ddZed3ddZed2d	d
Zed3ddZed2ddZ	ed2ddZ
ed2ddZed2ddZed2ddZed2ddZed2ddZed2ddZed2ddZed2dd Zed2d!d"Zed2d#d$Zed4d&d'Zed4d(d)Zed4d*d+Zd5d-d.Zd5d/d0Zd1S )6_UnixDefaultsz
    Default directories for Unix/Linux without XDG environment variable overrides.

    The XDG env var handling is in :class:`~platformdirs._xdg.XDGMixin`.
    r   strc                 C     |  tjdS )z
        :return: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or
         ``$XDG_DATA_HOME/$appname/$version``
        z~/.local/share_append_app_name_and_versionospath
expanduserselfr   r   r   user_data_dir#      z_UnixDefaults.user_data_dir	list[str]c                 C  s   |  d|  dgS )Nz/usr/local/sharez
/usr/sharer   r   r   r   r   _site_data_dirs+   s   z_UnixDefaults._site_data_dirsc                 C  r   )z
        :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or
         ``$XDG_CONFIG_HOME/$appname/$version``
        	~/.configr   r   r   r   r   user_config_dir/   r   z_UnixDefaults.user_config_dirc                 C  s   |  dgS )Nz/etc/xdgr    r   r   r   r   _site_config_dirs7   s   z_UnixDefaults._site_config_dirsc                 C  r   )z
        :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or
         ``$XDG_CACHE_HOME/$appname/$version``
        z~/.cacher   r   r   r   r   user_cache_dir;   r   z_UnixDefaults.user_cache_dirc                 C  s
   |  dS )zO:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z
/var/cacher    r   r   r   r   site_cache_dirC      
z_UnixDefaults.site_cache_dirc                 C  r   )z
        :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or
         ``$XDG_STATE_HOME/$appname/$version``
        z~/.local/stater   r   r   r   r   user_state_dirH   r   z_UnixDefaults.user_state_dirc                 C  s(   | j }| jrtj|d}| | |S )zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itlog)r(   opinionr   r   join_optionally_create_directoryr   r   r   r   r   user_log_dirP   s
   
z_UnixDefaults.user_log_dirc                 C  
   t ddS )zC:return: documents directory tied to the user, e.g. ``~/Documents``XDG_DOCUMENTS_DIRz~/Documents_get_user_media_dirr   r   r   r   user_documents_dirY   r'   z _UnixDefaults.user_documents_dirc                 C  r/   )zC:return: downloads directory tied to the user, e.g. ``~/Downloads``XDG_DOWNLOAD_DIRz~/Downloadsr1   r   r   r   r   user_downloads_dir^   r'   z _UnixDefaults.user_downloads_dirc                 C  r/   )zA:return: pictures directory tied to the user, e.g. ``~/Pictures``XDG_PICTURES_DIRz
~/Picturesr1   r   r   r   r   user_pictures_dirc   r'   z_UnixDefaults.user_pictures_dirc                 C  r/   )z=:return: videos directory tied to the user, e.g. ``~/Videos``XDG_VIDEOS_DIRz~/Videosr1   r   r   r   r   user_videos_dirh   r'   z_UnixDefaults.user_videos_dirc                 C  r/   )z;:return: music directory tied to the user, e.g. ``~/Music``XDG_MUSIC_DIRz~/Musicr1   r   r   r   r   user_music_dirm   r'   z_UnixDefaults.user_music_dirc                 C  r/   )z?:return: desktop directory tied to the user, e.g. ``~/Desktop``XDG_DESKTOP_DIRz	~/Desktopr1   r   r   r   r   user_desktop_dirr   r'   z_UnixDefaults.user_desktop_dirc                 C  sP   t jdrdt  }ndt  }t|tjs#t  dt  }| |S )a`  
        :return: runtime directory tied to the user, e.g. ``$XDG_RUNTIME_DIR/$appname/$version``.

        If ``$XDG_RUNTIME_DIR`` is unset, tries the platform default (``/var/run/user/$(id -u)`` on
        FreeBSD/OpenBSD/NetBSD, ``/run/user/$(id -u)`` otherwise). If the default is not writable,
        falls back to a temporary directory.
        freebsdopenbsdnetbsdz/var/run/user/z
/run/user/z	/runtime-)	sysplatform
startswithr   r   accessW_OKr   r   r-   r   r   r   user_runtime_dirw   s   	
z_UnixDefaults.user_runtime_dirc                 C  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.
        r>   z/var/runz/run)rB   rC   rD   r   r-   r   r   r   site_runtime_dir   s   
z_UnixDefaults.site_runtime_dirr   c                 C     |  | 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_multipathsite_data_dirr   r   r   r   site_data_path      z_UnixDefaults.site_data_pathc                 C  rI   )zf:return: config path shared by users, returns the first item, even if ``multipath`` is set to ``True``)rJ   site_config_dirr   r   r   r   site_config_path   rM   z_UnixDefaults.site_config_pathc                 C  rI   )zi:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)rJ   r&   r   r   r   r   site_cache_path   rM   z_UnixDefaults.site_cache_pathIterator[str]c                 c      | j V  | jE dH  dS )z4:yield: all user and site configuration directories.N)r#   r$   r   r   r   r   iter_config_dirs      z_UnixDefaults.iter_config_dirsc                 c  rR   )z+:yield: all user and site data directories.N)r   r!   r   r   r   r   iter_data_dirs   rT   z_UnixDefaults.iter_data_dirsN)r   r   )r   r   )r   r   )r   rQ   )__name__
__module____qualname____doc__propertyr   r!   r#   r$   r%   r&   r(   r.   r3   r5   r7   r9   r;   r=   rG   rH   rL   rO   rP   rS   rU   r   r   r   r   r      sT    
r   c                   @  s   e Zd ZdZdS )Unixaj  
    On Unix/Linux, we follow the `XDG Basedir Spec <https://specifications.freedesktop.org/basedir/latest/>`_.

    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>`.
    N)rV   rW   rX   rY   r   r   r   r   r[      s    r[   env_varr   fallback_tilde_pathc                 C  s   t |  }r|S tj|S )N)_get_user_dirs_folderr   r   r   )r\   r]   	media_dirr   r   r   r2      s   r2   key
str | Nonec                 C  s   t tjdd }| rJt }| }|d|   W d   n1 s*w   Y  | |d vr7d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/.

    r"   zuser-dirs.dirsz[top]
Ntop"z$HOME~)r   r   r   r   existsr   openread_stringreadstripreplace)r`   user_dirs_config_pathparserstreamr   r   r   r   r^      s   
r^   )r   r   )r\   r   r]   r   r   r   )r`   r   r   ra   )rY   
__future__r   r   rB   configparserr   pathlibr   tempfiler   typingr   r   _xdgr	   apir
   collections.abcr   rC   r   r   r[   r2   r^   __all__r   r   r   r   <module>   s,    
 

