a
    lc                     @   s   d Z ddlZddlZddlmZ ddlZddlmZ ddl	m
Z
mZmZmZmZmZ edddZedd	d
ZedddZdd ZdddZdS )z/Find files and directories which IPython uses.
    N)warn)import_item)get_home_dirget_xdg_dirget_xdg_cache_dircompress_user_writable_dirensure_dir_exists)returnc            	      C   sf  t j} t jj}d}t }t }d| v r0tdt | d| dd}|du r|||}|r||d}t	|rt
}t j|rtd|||| n*t j|rtd|||| n|}t jt j|}t j|rt	|std	| t }nJt j|sNt j|}t	|s@td
| t }nt j|dd t|tsbJ d|S )zGet the IPython directory for this platform and user.

    This uses the logic in `get_home_dir` to find the home directory
    and then adds .ipython to the end of the path.
    z.ipythonZIPYTHON_DIRzdThe environment variable IPYTHON_DIR is deprecated since IPython 3.0. Please use IPYTHONDIR instead.Z
IPYTHONDIRNipythonzDIgnoring {0} in favour of {1}. Remove {0} to get rid of this messagez>{0} is deprecated. Move link to {1} to get rid of this messagezEIPython dir '{0}' is not a writable location, using a temp directory.zHIPython parent '{0}' is not a writable location, using a temp directory.T)exist_okz:all path manipulation should be str(unicode), but are not.)osenvironpathjoinr   r   r   DeprecationWarninggetr   r   existsformatislinknormpath
expandusertempfilemkdtempdirnamemakedirs
isinstancestr)	envZpjoinZ	ipdir_defZhome_dirZxdg_diripdirZ	xdg_ipdircuparent r"   I/var/www/html/django/DPS/env/lib/python3.9/site-packages/IPython/paths.pyget_ipython_dir   sR    




r$   c                  C   sR   t  } | du rt S tj| d}tj|s@t| r@t| nt| sNt S |S )z;Get the cache directory it is created if it does not exist.Nr   )r   r$   r   r   r   r   r   r	   )Zxdgdirr   r"   r"   r#   get_ipython_cache_dirN   s    
r%   c                  C   s    t jtj} t| tsJ | S )z9Get the base directory where IPython itself is installed.)r   r   r   IPython__file__r   r   )r   r"   r"   r#   get_ipython_package_dir\   s    r(   c                 C   s>   | dkrt jt dS t| }|jdd}|dd}|S )zFind the path to an IPython module in this version of IPython.

    This will always find the version of the module that is in this importable
    IPython package. This will always return the path to the ``.py``
    version of the module.
    r&   z__init__.pyz.pycz.pyz.pyo)r   r   r   r(   r   r'   replace)Z
module_strmodZthe_pathr"   r"   r#   get_ipython_module_pathc   s    r+   defaultc              
   C   s\   ddl m}m} z|t | }W n2 |yT } ztd|  |W Y d}~n
d}~0 0 |jS )znFind the path to the folder associated with a given profile.

    I.e. find $IPYTHONDIR/profile_whatever.
    r   )
ProfileDirProfileDirErrorzCouldn't find profile %rN)IPython.core.profiledirr-   r.   find_profile_dir_by_namer$   IOErrorlocation)profiler-   r.   pder"   r"   r#   locate_profiler   s    $r6   )r,   )__doc__os.pathr   r   warningsr   r&   ZIPython.utils.importstringr   IPython.utils.pathr   r   r   r   r   r	   r   r$   r%   r(   r+   r6   r"   r"   r"   r#   <module>   s    
;