a
    @Df.                     @  s   d Z ddlmZ ddlZeeZddlZddlZddl	m
Z
mZmZmZ ddlmZ dZdddd	d
ZddddZdddddZdddddZdddddZdS )z

    )annotationsN)basenamedirnamejoinsplitext)NamedTemporaryFile)default_filenamedetect_current_filenametemp_filenamestr)extreturnc                 C  sp   | dkrt dt }|du r&t| S t|p4t }t|sFt|rNt| S tt	|\}}t
||d |  S )a   Generate a default filename with a given extension, attempting to use
    the filename of the currently running process, if possible.

    If the filename of the current process is not available (or would not be
    writable), then a temporary file with the given extension is returned.

    Args:
        ext (str) : the desired extension for the filename

    Returns:
        str

    Raises:
        RuntimeError
            If the extensions requested is ".py"

    pyz0asked for a default filename with 'py' extensionN.)RuntimeErrorr	   r
   r   osgetcwd
_no_access_shares_exec_prefixr   r   r   )r   filenamebasedirname_ r   Z/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/bokeh/io/util.pyr   4   s    r   z
str | None)r   c                  C  sV   ddl } d}|  }|durRz0|jr<|jddkr<|j}q|jd}W ~n~0 |S )z Attempt to return the filename of the currently running Python process

    Returns None if the filename cannot be detected.
    r   Nr   __main____file__)inspectcurrentframef_back	f_globalsget)r   r   framer   r   r   r	   V   s    r	   c                 C  s8   t d|  d}|jW  d   S 1 s*0    Y  dS )zG Generate a temporary, writable filename with the given extension

    r   )suffixN)r   r   )r   fr   r   r   r
   j   s    r
   bool)r   r   c                 C  s   t | t jt jB  S )zG Return True if the given base dir is not accessible or writeable

    )r   accessW_OKX_OK)r   r   r   r   r   w   s    r   c                 C  s   t j}|duo| |S )zA Whether a give base directory is on the system exex prefix

    N)sysexec_prefix
startswith)r   prefixr   r   r   r   }   s    r   )__doc__
__future__r   logging	getLogger__name__logr   r)   os.pathr   r   r   r   tempfiler   __all__r   r	   r
   r   r   r   r   r   r   <module>   s   
"