U eJ@sdZddlmZddlZddlmZmZddlmZddl m Z m Z m Z ddl mZmZddlmZmZmZGd d d ZGd d d ZGd ddeZGdddeeZGdddeZGdddeeZddddd d gZdS)aG Virtual environments in the traditional sense are built as reference to the host python. This file allows declarative references to elements on the file system, allowing our system to automatically detect what modes it can support given the constraints: e.g. can the file system symlink, can the files be read, executed, etc. ) annotationsN)ABCabstractmethod) OrderedDict)S_IXGRPS_IXOTHS_IXUSR)fs_is_case_sensitivefs_supports_symlink)copymake_exesymlinkc@seZdZdZdZdZdS)RefMustNAr r N)__name__ __module__ __qualname__rCOPYSYMLINKrrZ/opt/hc_python/lib/python3.8/site-packages/virtualenv/create/via_global_ref/builtin/ref.pyrsrc@seZdZdZdZdZdS)RefWhenANYr r N)rrrrrrrrrrrsrc@szeZdZdZeZeZej e j fddddZ ddddZ ed d Zed d Zed dZeddZddZdS)PathRefzABase class that checks if a file reference can be symlink/copied.NonereturncCsp||_||_||_z||_Wntk r:d|_YnX|jrFdnd|_|jrVdnd|_|jrfdnd|_dSNF)mustwhensrcexistsOSError _can_read _can_copy _can_symlinkselfr rrrrr__init__$s zPathRef.__init__strcCs|jjd|jdS)N(src=)) __class__rr r'rrr__repr__0szPathRef.__repr__c Csp|jdkrj|jrTz"|jd d|_W5QRXWqjtk rPd|_YqjXntt|jtj|_|jS)NrbTF) r#r is_fileopenr"osaccessr)R_OKr-rrrcan_read3s  zPathRef.can_readcCs.|jdkr(|jtjkr |j|_n|j|_|jSN)r$rrr can_symlinkr5r-rrrcan_copy@s    zPathRef.can_copycCs4|jdkr.|jtjkr |j|_n|jo*|j|_|jSr6)r%rrrr8FS_SUPPORTS_SYMLINKr5r-rrrr7Is    zPathRef.can_symlinkcCstdSr6)NotImplementedError)r'creatorsymlinksrrrrunRsz PathRef.runcCs,|jtjkrtS|jtjkr tS|r(tStSr6)rrrr rr )r'r<rrrmethodVs   zPathRef.methodN)rrr__doc__r r9r FS_CASE_SENSITIVErrrrr(r.propertyr5r8r7rr=r>rrrrrs     rcsHeZdZdZejejfddfdd Ze ddZ e dd Z Z S) ExePathRefzJBase class that checks if a executable can be references via symlink/copy.rrcst|||d|_dSr6)superr(_can_runr&r,rrr(aszExePathRef.__init__cCs|jr |jSdSr)r9can_runr-rrrr7eszExePathRef.can_symlinkcCsD|jdkr>|jj}tttfD]}||@r2d|_q>q d|_|jS)NTF)rDr statst_moderrr)r'modekeyrrrrFks  zExePathRef.can_run) rrrr?rrrrr(rAr7rF __classcell__rrrErrB^s  rBcs8eZdZdZejejfddfdd ZddZ Z S) PathRefToDestzLink a path on the file system.rrcst|||||_dSr6)rCr(dest)r'r rMrrrErrr({szPathRefToDest.__init__cCs`|||j}||}t|tr&|n|f}|jsF|jjddd|D]}||j|qJdS)NT)parentsexist_ok)rMr r> isinstancelistparentr!mkdir)r'r;r<rMr>Z dest_iterabledstrrrr=s  zPathRefToDest.run) rrrr?rrrrr(r=rKrrrErrLxsrLc@s>eZdZdZejejfddddZddZ ddd d Z d S) ExePathRefToDestz#Link a exe path on the file system.rrcCsdt||||t||||||jsBttdd|D}|d|_|dd|_||_ dS)Ncss|]}|dfVqdSr6)lower).0irrr sz,ExePathRefToDest.__init__..r) rBr(rLr@rQrkeysbasealiasesrM)r'r targetsrMrrrrrr(s zExePathRefToDest.__init__cCs|||jj}||j}||}||j||sr r]r!unlink symlink_tor )r'r;r<bin_dirrMr>extraZ link_filerrrr=s     zExePathRefToDest.runr)cCs|jjd|jd|jdS)Nr*z, alias=r+)r,rr r]r-rrrr.szExePathRefToDest.__repr__N) rrrr?rrrrr(r=r.rrrrrUs rU)r? __future__rr2abcrr collectionsrrGrrrZvirtualenv.infor r Zvirtualenv.util.pathr r r rrrrBrLrU__all__rrrrs(  @#