a  zeZ#@sJdZddlZddlZddlZddlZddlZddlZddlmZm Z m Z ddlm Z ddl m Z ddlmZmZmZmZddlmZeeZeeZzddlZee7ZWneyedYn0zddlZee7ZWneyed Yn0d d Zd d ZddZddZ ddZ!ddZ"dddZ#ddZ$dddZ%dS)zUtilities related archives. N)IterableListOptional)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONS XZ_EXTENSIONSZIP_EXTENSIONS) ensure_dirzbz2 module is not availablezlzma module is not availablecCstd}t||S)zBGet the current umask which involves having to set it temporarily.r)osumask)maskr_/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py current_umask+s  rcCsh|dd}d|vrHd|vr4|d|dksd}n8|trRd}n$|drfd}ntd|d }tj||d d }zt d d | D}| D]}|j }|rt |d}t j||}t||sd}t|||||rt|q|rhz|||WnDtyd} z*td||j | WYd} ~ qWYd} ~ n d} ~ 00qz||} WnHttfy} z*td||j | WYd} ~ qWYd} ~ n d} ~ 00tt j|| dusJt|d} t| | Wdn1s 0Y| ||||jd@rt |qW|n |0dS)a Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. z.gzz.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*zutf-8)encodingcSsg|] }|jqSr)rH).0memberrrr zuntar_file..rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr5r()!r lowerr?rr loggerwarningtarfiler6r getmembersrHrr rr<r'rr>isdirissym_extract_member Exception extractfileKeyErrorAttributeErrorr=r@rArButimer1r*) r;rCr1tarrGrRrIrrKexcrLrMrrr untar_filest      $" ,   rdcCstj|}|dks,|ts,t|rDt|||d dnR|dkslt |sl|t t t rxt||ntd|||td|dS)Nzapplication/zipz.whl)rDzapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r rrealpathrUr?r r7 is_zipfilerNrX is_tarfilerrr rdrVcriticalr)r;rC content_typerrr unpack_files,   rj)T)N)&__doc__loggingr r@r.rXr7typingrrrrpip._internal.exceptionsrpip._internal.utils.filetypesrrr r pip._internal.utils.miscr getLogger__name__rVSUPPORTED_EXTENSIONSbz2 ImportErrordebuglzmarrr r'r*r2rNrdrjrrrrsB            /U