a
    Lcòf	  ã                   @   s`   d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	 d dl
mZ dd„ Zdd„ Zd	d
„ ZdS )é    N)ÚabspathÚdirnameÚjoinÚnormcaseÚsep)ÚPath)ÚSuspiciousFileOperationc                 G   sj   t t| g|¢R Ž ƒ}t | ƒ}t|ƒ t|t ƒ¡sft|ƒt|ƒkrftt|ƒƒt|ƒkrftd ||¡ƒ‚|S )zî
    Join one or more path components to the base path component intelligently.
    Return a normalized, absolute version of the final path.

    Raise ValueError if the final path isn't located inside of the base path
    component.
    zGThe joined path ({}) is located outside of the base path component ({}))r   r   r   Ú
startswithr   r   r   Úformat)ÚbaseÚpathsZ
final_pathÚ	base_path© r   úM/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/django/utils/_os.pyÚ	safe_join	   s    	ÿþýÿÿr   c               
   C   s†   t  ¡ �j} tj | d¡}tj | d¡}t |¡ zt ||¡ d}W n ttfy^   d}Y n0 |W  d  ƒ S 1 sx0    Y  dS )z¶
    Return whether or not creating symlinks are supported in the host platform
    and/or if they are allowed to be created (e.g. on Windows it requires admin
    permissions).
    ÚoriginalÚsymlinkTFN)	ÚtempfileÚTemporaryDirectoryÚosÚpathr   Úmakedirsr   ÚOSErrorÚNotImplementedError)Útemp_dirZoriginal_pathZsymlink_pathÚ	supportedr   r   r   Úsymlinks_supported&   s    


r   c                 C   s2   t | tƒr| S t | tƒs*tdt| ƒj ƒ‚t| ƒS )z@Convert value to a pathlib.Path instance, if not already a Path.zInvalid path type: %s)Ú
isinstancer   ÚstrÚ	TypeErrorÚtypeÚ__name__)Úvaluer   r   r   Úto_path8   s
    

r#   )r   r   Úos.pathr   r   r   r   r   Úpathlibr   Zdjango.core.exceptionsr   r   r   r#   r   r   r   r   Ú<module>   s   