o
    fi                     @   s   d Z ddlZddlmZ ddlmZmZ g dZdededefd	d
Z	dedee dee fddZ
defddZdee fddZdefddZdee fddZdefddZdee fddZdefddZe Ze Ze Ze Ze Ze ZdS )a  XDG Base Directory Specification variables.

xdg_cache_home(), xdg_config_home(), xdg_data_home(), and xdg_state_home()
return pathlib.Path objects containing the value of the environment variable
named XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME, and XDG_STATE_HOME
respectively, or the default defined in the specification if the environment
variable is unset, empty, or contains a relative path rather than absolute
path.

xdg_config_dirs() and xdg_data_dirs() return a list of pathlib.Path
objects containing the value, split on colons, of the environment
variable named XDG_CONFIG_DIRS and XDG_DATA_DIRS respectively, or the
default defined in the specification if the environment variable is
unset or empty. Relative paths are ignored, as per the specification.

xdg_runtime_dir() returns a pathlib.Path object containing the value of
the XDG_RUNTIME_DIR environment variable, or None if the environment
variable is not set, or contains a relative path rather than absolute path.

    NPath)ListOptional)xdg_cache_homexdg_config_dirsxdg_config_homexdg_data_dirsxdg_data_homexdg_runtime_dirxdg_state_homeXDG_CACHE_HOMEXDG_CONFIG_DIRSXDG_CONFIG_HOMEXDG_DATA_DIRSXDG_DATA_HOMEXDG_RUNTIME_DIRvariabledefaultreturnc                 C   s(   t j| }|rt j|rt|S |S )a  Read an environment variable as a path.

    The environment variable with the specified name is read, and its
    value returned as a path. If the environment variable is not set, is
    set to the empty string, or is set to a relative rather than
    absolute path, the default value is returned.

    Parameters
    ----------
    variable : str
        Name of the environment variable.
    default : Path
        Default value.

    Returns
    -------
    Path
        Value from environment or default.

    )osenvirongetpathisabsr   )r   r   value r   @/home/ubuntu/.local/lib/python3.10/site-packages/xdg/__init__.py_path_from_env=   s   r   c                 C   s0   t j| }|rdd |dD }|r|S |S )a<  Read an environment variable as a list of paths.

    The environment variable with the specified name is read, and its
    value split on colons and returned as a list of paths. If the
    environment variable is not set, or set to the empty string, the
    default value is returned. Relative paths are ignored, as per the
    specification.

    Parameters
    ----------
    variable : str
        Name of the environment variable.
    default : List[Path]
        Default value.

    Returns
    -------
    List[Path]
        Value from environment or default.

    c                 S   s    g | ]}t j|rt|qS r   )r   r   r   r   .0r   r   r   r   
<listcomp>r   s
    z#_paths_from_env.<locals>.<listcomp>:)r   r   r   split)r   r   r   pathsr   r   r   _paths_from_envY   s   r%   c                   C      t dt d S )z.Return a Path corresponding to XDG_CACHE_HOME.r   z.cacher   r   homer   r   r   r   r   z      r   c                   C   s   t dtdgS )z8Return a list of Paths corresponding to XDG_CONFIG_DIRS.r   z/etc/xdg)r%   r   r   r   r   r   r      s   r   c                   C   r&   )z/Return a Path corresponding to XDG_CONFIG_HOME.r   z.configr'   r   r   r   r   r      r)   r   c                   C   s   t ddd ddD S )z6Return a list of Paths corresponding to XDG_DATA_DIRS.r   c                 S   s   g | ]}t |qS r   r   r   r   r   r   r!      s    z!xdg_data_dirs.<locals>.<listcomp>z/usr/local/share/:/usr/share/r"   )r%   r#   r   r   r   r   r	      s   r	   c                   C      t dt d d S )z-Return a Path corresponding to XDG_DATA_HOME.r   .localsharer'   r   r   r   r   r
         r
   c                  C   s&   t d} | rt j| rt| S dS )zReturn a Path corresponding to XDG_RUNTIME_DIR.

    If the XDG_RUNTIME_DIR environment variable is not set, None will be
    returned as per the specification.

    r   N)r   getenvr   r   r   )r   r   r   r   r      s   
r   c                   C   r*   )z.Return a Path corresponding to XDG_STATE_HOME.XDG_STATE_HOMEr+   stater'   r   r   r   r   r      r-   r   )__doc__r   pathlibr   typingr   r   __all__strr   r%   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s(   !
