
v^                 @   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   s   t  t |  |   } t  |   } t |  j t | t   r t |  t |  k r t t |   t |  k r t d j | |    | 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   2/tmp/pip-build-8lau8j11/django/django/utils/_os.py	safe_join	   s     r   c              C   s   t  j   } }  t j j |  d  } t j j |  d  } t j |  y t j | |  d } Wn t t f k
 r d } Yn X| SWd QRXd 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).
    ZoriginalsymlinkTFN)	tempfileTemporaryDirectoryospathr   makedirsr   OSErrorNotImplementedError)temp_dirZoriginal_pathZsymlink_path	supportedr   r   r   symlinks_supported#   s    
r   c             C   sE   t  |  t  r |  St  |  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_path5   s
    r"   )r   r   os.pathr   r   r   r   r   Zpathlibr   Zdjango.core.exceptionsr   r   r   r"   r   r   r   r   <module>   s   (