
    Ui                     t    d dl Z d dlZd dlmZmZmZmZmZmZ d dl	m
Z
 d dlmZ ddddZddZd Zd	 Zd
 Zy)    N)abspathcurdirdirnamejoinnormcasesep)Path)SuspiciousFileOperation)parent_modec                H   t         j                  j                  |       \  }}|s"t         j                  j                  |      \  }}|rm|rkt         j                  j                  |      sL	 |t	        ||||       nt	        ||       t        }t        |t              rt        t        d      }||k(  ry	 t        j                  | |       t        j                  | |       y# t
        $ r Y ew xY w# t        $ r% |rt         j                  j                  |       s Y yw xY w)a{  makedirs(name [, mode=0o777][, exist_ok=False][, parent_mode=None])

    Super-mkdir; create a leaf directory and all intermediate ones.  Works like
    mkdir, except that any intermediate path segment (not just the rightmost)
    will be created if it does not exist. If the target directory already
    exists, raise an OSError if exist_ok is False. Otherwise no exception is
    raised.  If parent_mode is not None, it will be used as the mode for any
    newly-created, intermediate-level directories. Otherwise, intermediate
    directories are created with the default permissions (respecting umask).
    This is recursive.

    N)modeexist_okr   )r   ASCII)ospathsplitexistsmakedirsFileExistsErrorr   
isinstancebytesmkdirchmodOSErrorisdir)namer   r   r   headtailcdirs          C/var/www/opsc/venv/lib/python3.12/site-packages/django/utils/_os.pyr   r      s     t$JD$WW]]4(
dRWW^^D1		&{X; 1 dE")D4<
t 	t  		    rww}}T2  3s$   +C$ 7,C3 $	C0/C03+D! D!c                 "    t        | |||       y)zBCreate directories recursively with explicit `mode` on each level.)r   r   r   r   N)r   )r   r   r   s      r    safe_makedirsr"   <   s    $TH$G    c                 >   t        t        | g|       }t        |       }t        |      j                  t        |t        z               sRt        |      t        |      k7  r;t        t        |            t        |      k7  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 SuspiciousFileOperation 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paths
final_path	base_paths       r    	safe_joinr+   A   s     d+U+,JI Z ++HY_,EFZ HY$77HY'(HY,??%#VJ	:
 	
 r#   c                  d   t        j                         5 } t        j                  j	                  | d      }t        j                  j	                  | d      }t        j
                  |       	 t        j                  ||       d}|cddd       S # t        t        f$ r d}Y w xY w# 1 sw Y   yxY w)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TemporaryDirectoryr   r   r   r   r.   r   NotImplementedError)temp_diroriginal_pathsymlink_path	supporteds       r    symlinks_supportedr6   _   s     
	$	$	& 	(Xz:ww||Hi8
M"	JJ}l3I 	 	 ,- 	I		 	s0   AB&,BB&B# B&"B##B&&B/c                     t        | t              r| S t        | t              s!t        dt	        |       j
                  z        t        |       S )z@Convert value to a pathlib.Path instance, if not already a Path.zInvalid path type: %s)r   r	   str	TypeErrortype__name__)values    r    to_pathr=   q   s@    %s#/$u+2F2FFGG;r#   )i  F)r   r/   os.pathr   r   r   r   r   r   pathlibr	   django.core.exceptionsr
   r   r"   r+   r6   r=    r#   r    <module>rB      s9    	  A A  :,d ,^H
<$r#   