File: //lib64/python3.8/distutils/__pycache__/archive_util.cpython-38.opt-1.pyc
U
e5d|! @ sD d Z ddlZddlmZ ddlZzddlZW n ek
rD dZY nX ddlmZ ddl m
Z
ddlmZ ddl
mZ zddlmZ W n ek
r dZY nX zdd lmZ W n ek
r dZY nX d
d Zdd
Zd#ddZd$ddZedgdfedgdfedgdfedgdfedgdfeg dfdZdd Zd%d!d"ZdS )&zodistutils.archive_util
Utility functions for creating archive files (tarballs, zip files,
that sort of thing). N)warn)DistutilsExecError)spawn)mkpath)log)getpwnam)getgrnamc C sN t dks| dkrdS zt | }W n tk
r8 d}Y nX |dk rJ|d S dS )z"Returns a gid, given a group name.N )r KeyErrornameresult r ./usr/lib64/python3.8/distutils/archive_util.py_get_gid s
r c C sN t dks| dkrdS zt | }W n tk
r8 d}Y nX |dk rJ|d S dS )z"Returns an uid, given a user name.Nr )r r
r r r r _get_uid+ s
r gzipc s. dddddd}dddd d
}|dk r:|| kr:td| d
} |dkrZ| ||d7 } ttj| |d ddl}
t d t
t fdd}|s|
| d|| }z|j||d W 5 |
X |dkr*tdt | || }
tjdkr|| |
g}n
|d| g}t||d |
S | S )a= Create a (possibly compressed) tar file from all the files under
'base_dir'.
'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or
None. ("compress" will be deprecated in Python 3.2)
'owner' and 'group' can be used to define an owner and a group for the
archive that is being built. If not provided, the current owner and group
will be used.
The output tar file will be named 'base_dir' + ".tar", possibly plus
the appropriate compression extension (".gz", ".bz2", ".xz" or ".Z").
Returns the output filename.
Zgzbz2xz )r bzip2r Ncompressz.gzz.bz2z.xzz.Z)r r r r NzKbad value for 'compress': must be None, 'gzip', 'bzip2', 'xz' or 'compress'z.tarr dry_runr zCreating tar archivec s, d k r | _ | _d k r(| _| _| S )N)gidZgnameuiduname)Ztarinfor groupownerr r r _set_uid_gida s z"make_tarball.<locals>._set_uid_gidzw|%s)filterz'compress' will be deprecated.Zwin32z-f)keys
ValueErrorgetr ospathdirnametarfiler infor r opencloseaddr PendingDeprecationWarningsysplatformr ) base_namebase_dirr verboser r r Ztar_compressionZcompress_extZarchive_namer( r tarZcompressed_namecmdr r r make_tarball7 sB
r5 c
C s | d }t tj||d tdkrp|r.d}nd}ztd|||g|d W n tk
rj td| Y nX n8td|| |sztj |d tj
d
}W n& tk
r tj |d tjd
}Y nX | |tj
krtjtj|d}||| td| t|D ]\}} }
| D ]6}tjtj||d}||| td| q|
D ]B}tjtj||}tj|rV||| td| qVqW 5 Q R X |S )
av Create a zip file from all the files under 'base_dir'.
The output zip file will be named 'base_name' + ".zip". Uses either the
"zipfile" Python module (if available) or the InfoZIP "zip" utility
(if installed and found on the default search path). If neither tool is
available, raises DistutilsExecError. Returns the name of the output zip
file.
z.zipr Nz-rz-rqzipzkunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to itw)Zcompressionr zadding '%s')r r% r&