<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    Ĥa                 @  s   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	 ej
drZd dlmZ nd	d
ddZG dd de	ZdddddZdgZdS )    )annotationsN)ConfigParser)Path   )PlatformDirsABClinux)getuidint)returnc               C  s   t dd S )Nzshould only be used on Linux)RuntimeError r   r   B/opt/alt/python37/lib/python3.7/site-packages/platformdirs/unix.pyr      s    r   c               @  s   e Zd ZdZeddddZeddddZdddd	d
ZeddddZeddddZ	eddddZ
eddddZeddddZeddddZeddddZeddddZeddddZddddd Zd!S )"UnixaD  
    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>`.
    str)r
   c             C  s,   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   r   r   r   user_data_dir   s    zUnix.user_data_dirc             C  s.   t jdd}| s$dt j 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_DIRSr   z/usr/local/sharez
/usr/share)r   r   r   r   pathsep_with_multi_path)r   r   r   r   r   site_data_dir)   s    zUnix.site_data_dir)r   r
   c               s<   | tj} js|dd } fdd|D }tj|S )Nr   r   c               s   g | ]}  tj|qS r   )r   r   r   r   ).0p)r   r   r   
<listcomp>:   s    z)Unix._with_multi_path.<locals>.<listcomp>)splitr   r   	multipathjoin)r   r   	path_listr   )r   r   r   6   s
    zUnix._with_multi_pathc             C  s,   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	~/.config)r   r   r   r   r   r   r   )r   r   r   r   r   user_config_dir=   s    zUnix.user_config_dirc             C  s$   t jdd}| sd}| |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_DIRSr   z/etc/xdg)r   r   r   r   r   )r   r   r   r   r   site_config_dirH   s    zUnix.site_config_dirc             C  s,   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~/.cache)r   r   r   r   r   r   r   )r   r   r   r   r   user_cache_dirU   s    zUnix.user_cache_dirc             C  s,   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/state)r   r   r   r   r   r   r   )r   r   r   r   r   user_state_dir`   s    zUnix.user_state_dirc             C  s   | j }| jrtj|d}|S )zx
        :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it
        log)r+   opinionr   r   r$   )r   r   r   r   r   user_log_dirk   s    zUnix.user_log_dirc             C  s6   t d}|dkr2tjdd }|s2tjd}|S )zU
        :return: documents directory tied to the user, e.g. ``~/Documents``
        ZXDG_DOCUMENTS_DIRNr   z~/Documents)_get_user_dirs_folderr   r   r   r   r   r   )r   Zdocuments_dirr   r   r   user_documents_diru   s    zUnix.user_documents_dirc             C  s,   t jdd}| s"dt  }| |S )z
        :return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or
         ``$XDG_RUNTIME_DIR/$appname/$version``
        ZXDG_RUNTIME_DIRr   z
/run/user/)r   r   r   r   r   r   )r   r   r   r   r   user_runtime_dir   s    zUnix.user_runtime_dirr   c             C  s   |  | 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   r   r   r   site_data_path   s    zUnix.site_data_pathc             C  s   |  | jS )zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)r4   r)   )r   r   r   r   site_config_path   s    zUnix.site_config_path)	directoryr
   c             C  s   | j r|tjd }t|S )Nr   )r#   r"   r   r   r   )r   r7   r   r   r   r4      s    z%Unix._first_item_as_path_if_multipathN)__name__
__module____qualname____doc__propertyr   r   r   r'   r)   r+   r-   r0   r2   r3   r5   r6   r4   r   r   r   r   r      s   

r   r   z
str | None)keyr
   c          	   C  s   t jt jd}t j|rt }t|}|d|	   W dQ R X | |d kr\dS |d |  
d}|dt jd}|S dS )zjReturn 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$   r   r'   existsr   openread_stringreadr   replacer   )r=   Zuser_dirs_config_pathparserstreamr   r   r   r   r1      s    
r1   )
__future__r   r   sysconfigparserr   Zpathlibr   Zapir   platform
startswithr   r   r1   __all__r   r   r   r   <module>   s    