관리-도구
편집 파일: unarchive.cpython-39.opt-1.pyc
a �����)g'�����������������������@���s$��d�dl�mZmZmZ�eZdZdZdZd�dl Z d�dl Z d�dlZd�dlZd�dl Z d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlmZ�d�dlmZmZ�d�dlmZmZmZ�d�d lmZ�d�d l m!Z!�d�dl"m#Z#�d�dl$m%Z%�zd�d l&m'Z'�W�n �e(�y���d�d l)m'Z'�Y�n0�e�*d�Z+e�*d�Z,e�*d�Z-e�*d�Z.e�*d�Z/e�*d�Z0e�*d�Z1e�*d�Z2e�*d�Z3dd��Z4dd��Z5G�dd��de6�Z7G�dd��de8�Z9G�dd ��d e8�Z:G�d!d"��d"e:�Z;G�d#d$��d$e:�Z<G�d%d&��d&e:�Z=G�d'd(��d(e:�Z>G�d)d*��d*e9�Z?d+d,��Z@d-d.��ZAeBd/k�r eA���dS�)0�����)�absolute_import�division�print_functiona��� --- module: unarchive version_added: '1.4' short_description: Unpacks an archive after (optionally) copying it from the local machine description: - The C(unarchive) module unpacks an archive. It will not unpack a compressed file that does not contain an archive. - By default, it will copy the source file from the local system to the target before unpacking. - Set C(remote_src=yes) to unpack an archive which already exists on the target. - If checksum validation is desired, use M(ansible.builtin.get_url) or M(ansible.builtin.uri) instead to fetch the file and set C(remote_src=yes). - For Windows targets, use the M(community.windows.win_unzip) module instead. options: src: description: - If C(remote_src=no) (default), local path to archive file to copy to the target server; can be absolute or relative. If C(remote_src=yes), path on the target server to existing archive file to unpack. - If C(remote_src=yes) and C(src) contains C(://), the remote machine will download the file from the URL first. (version_added 2.0). This is only for simple cases, for full download support use the M(ansible.builtin.get_url) module. type: path required: true dest: description: - Remote absolute path where the archive should be unpacked. - The given path must exist. Base directory is not created by this module. type: path required: true copy: description: - If true, the file is copied from local controller to the managed (remote) node, otherwise, the plugin will look for src archive on the managed machine. - This option has been deprecated in favor of C(remote_src). - This option is mutually exclusive with C(remote_src). type: bool default: yes creates: description: - If the specified absolute path (file or directory) already exists, this step will B(not) be run. - The specified absolute path (file or directory) must be below the base path given with C(dest:). type: path version_added: "1.6" io_buffer_size: description: - Size of the volatile memory buffer that is used for extracting files from the archive in bytes. type: int default: 65536 version_added: "2.12" list_files: description: - If set to True, return the list of files that are contained in the tarball. type: bool default: no version_added: "2.0" exclude: description: - List the directory and file entries that you would like to exclude from the unarchive action. - Mutually exclusive with C(include). type: list default: [] elements: str version_added: "2.1" include: description: - List of directory and file entries that you would like to extract from the archive. If C(include) is not empty, only files listed here will be extracted. - Mutually exclusive with C(exclude). type: list default: [] elements: str version_added: "2.11" keep_newer: description: - Do not replace existing files that are newer than files from the archive. type: bool default: no version_added: "2.1" extra_opts: description: - Specify additional options by passing in an array. - Each space-separated command-line option should be a new element of the array. See examples. - Command-line options with multiple elements must use multiple lines in the array, one for each element. type: list elements: str default: "" version_added: "2.1" remote_src: description: - Set to C(true) to indicate the archived file is already on the remote system and not local to the Ansible controller. - This option is mutually exclusive with C(copy). type: bool default: no version_added: "2.2" validate_certs: description: - This only applies if using a https URL as the source of the file. - This should only set to C(false) used on personally controlled sites using self-signed certificate. - Prior to 2.2 the code worked as if this was set to C(true). type: bool default: yes version_added: "2.2" extends_documentation_fragment: - action_common_attributes - action_common_attributes.flow - action_common_attributes.files - decrypt - files attributes: action: support: full async: support: none bypass_host_loop: support: none check_mode: support: partial details: Not supported for gzipped tar files. diff_mode: support: partial details: Uses gtar's C(--diff) arg to calculate if changed or not. If this C(arg) is not supported, it will always unpack the archive. platform: platforms: posix safe_file_operations: support: none vault: support: full todo: - Re-implement tar support using native tarfile module. - Re-implement zip support using native zipfile module. notes: - Requires C(zipinfo) and C(gtar)/C(unzip) command on target host. - Requires C(zstd) command on target host to expand I(.tar.zst) files. - Can handle I(.zip) files using C(unzip) as well as I(.tar), I(.tar.gz), I(.tar.bz2), I(.tar.xz), and I(.tar.zst) files using C(gtar). - Does not handle I(.gz) files, I(.bz2) files, I(.xz), or I(.zst) files that do not contain a I(.tar) archive. - Existing files/directories in the destination which are not in the archive are not touched. This is the same behavior as a normal archive extraction. - Existing files/directories in the destination which are not in the archive are ignored for purposes of deciding if the archive should be unpacked or not. seealso: - module: community.general.archive - module: community.general.iso_extract - module: community.windows.win_unzip author: Michael DeHaan au�� - name: Extract foo.tgz into /var/lib/foo ansible.builtin.unarchive: src: foo.tgz dest: /var/lib/foo - name: Unarchive a file that is already on the remote machine ansible.builtin.unarchive: src: /tmp/foo.zip dest: /usr/local/bin remote_src: yes - name: Unarchive a file that needs to be downloaded (added in 2.0) ansible.builtin.unarchive: src: https://example.com/example.zip dest: /usr/local/bin remote_src: yes - name: Unarchive a file with extra options ansible.builtin.unarchive: src: /tmp/foo.zip dest: /usr/local/bin extra_opts: - --transform - s/^xxx/yyy/ a_�� dest: description: Path to the destination directory. returned: always type: str sample: /opt/software files: description: List of all the files in the archive. returned: When I(list_files) is True type: list sample: '["file1", "file2"]' gid: description: Numerical ID of the group that owns the destination directory. returned: always type: int sample: 1000 group: description: Name of the group that owns the destination directory. returned: always type: str sample: "librarians" handler: description: Archive software handler used to extract and decompress the archive. returned: always type: str sample: "TgzArchive" mode: description: String that represents the octal permissions of the destination directory. returned: always type: str sample: "0755" owner: description: Name of the user that owns the destination directory. returned: always type: str sample: "paul" size: description: The size of destination directory in bytes. Does not include the size of files or subdirectories contained within. returned: always type: int sample: 36 src: description: - The source archive's path. - If I(src) was a remote web URL, or from the local ansible controller, this shows the temporary location where the download was stored. returned: always type: str sample: "/home/paul/test.tar.gz" state: description: State of the destination. Effectively always "directory". returned: always type: str sample: "directory" uid: description: Numerical ID of the user that owns the destination directory. returned: always type: int sample: 1000 N)�partial)�ZipFile� BadZipfile)�to_bytes� to_native�to_text)� AnsibleModule)�get_bin_path)�get_best_parsable_locale)� fetch_file)�quotez: Uid differs$z: Gid differs$z: Mode differs$z: Mod time differs$z4: : Warning: Cannot stat: No such file or directory$z2: Warning: Cannot stat: No such file or directory$z([r-][w-][SsTtx-]){3}z: Invalid ownerz: Invalid groupc�����������������C���s`���t��d�}t|�d��4}tt|j|�d�D�]}t��||�}q(W�d����n1�sN0����Y��|d@�S�)z# Return a CRC32 checksum of a file ������rbNl������)�binascii�crc32�open�iterr����read)�pathZbuffer_size�crc�fZb_block��r����=/usr/lib/python3.9/site-packages/ansible/modules/unarchive.pyr�����s ���� ,r���c�����������������C���s���t��dd|��S�)z6 Quote meta-characters in the args for the unix shell z([^A-Za-z0-9_])z\\\1)�re�sub)�stringr���r���r����shell_escape%��s����r���c�������������������@���s���e�Zd�ZdS�)�UnarchiveErrorN)�__name__� __module__�__qualname__r���r���r���r���r ���*��s���r ���c�������������������@���sP���e�Zd�Zdd��Zdd��Zdd��Zdd��Zed d ���Zdd��Z d d��Z dd��ZdS�)� ZipArchivec�����������������C���sz���||�_�||�_||�_|jd�|�_||�_|jd�|�_|jd�|�_g�|�_|�jjd�|�_ d�|�_ d�|�_g�|�_t ��|�_d|�_d|�_d�S�)N� extra_opts�io_buffer_size�exclude�include��)��unzip�cmd_path)�zipinfo�zipinfo_cmd_path)�src�b_dest� file_args�params�opts�moduler&����excludes�includes� include_filesr,���r.����_files_in_archive�dict� _infodict�zipinfoflag�binaries��selfr/���r0���r1���r4���r���r���r����__init__0��s����zZipArchive.__init__c�����������������C���sd���|ddd��}d}t�dd�D�]<}t�dd�D�],}||d|���dv�r*|d|d|���7�}q*q||�@�S�)zA Convert a Unix permission string (rw-r--r--) into a mode (0644) N���r�������)�r�w�x�s�t����)�range)r>���Zmodestr�umaskZrevstr�mode�j�ir���r���r����_permstr_to_octalD��s����zZipArchive._permstr_to_octalc�����������������C���sz���|�j��|�jd|�jg�\}}}|r.td|�j���|���dd��D�]6}|�d�d�}|�j�|d���t |d��|�j |d�<�q>d�S�)Nz-vz,Neither python zipfile nor unzip can read %srA��������������)r4����run_commandr,���r/���r ���� splitlines�splitr8����append�intr:���)r>����rc�out�err�line�fieldsr���r���r����_legacy_file_listQ��s����zZipArchive._legacy_file_listc�������������� ���C���s����|�j�r|�j�|�S�zt|�j�}W�nD�tyb�}�z,|jd�����d�rL|�����n��W�Y�d�}~nRd�}~0�0�z$|���D�]}t |j �|�j�|j<�qnW�n"�ty����|� ���td��Y�n0�|�j�|�S�)Nr����bad magic numberz#Unable to list files in the archive)r:���r���r/���r����args�lower� startswithr[����infolistrU���ZCRC�filename� Exception�closer ���)r>���r����archive�e�itemr���r���r����_crc32[��s���� zZipArchive._crc32c�������������� ���C���s4��|�j�r|�j�S�g�|�_�zt|�j�}W�nD�tyd�}�z,|jd�����d�rN|�����n��W�Y�d�}~n�d�}~0�0�z�|���D�]r}|�j r�|�j D�] }t � ||�r�|�j��t|���q�qpd}|�j r�|�j D�]}t � ||�r�d}�q�q�|sp|�j��t|���qpW�n>�t�y$�}�z$|����tdt|����W�Y�d�}~n d�}~0�0�|����|�j�S�)Nr���r\���FT�'Unable to list files in the archive: %s)r8���r���r/���r���r]���r^���r_���r[���Znamelistr7����fnmatchrT���r ���r5���rb���rc���r ���)r>���rd���re����memberr(����exclude_flagr'���r���r���r����files_in_archiver��s8���� &zZipArchive.files_in_archivec�����������,������C���s2 ��|�j�r|�j|�j�dd|�jg}n|�jdd|�jg}|�jrD|�dg|�j���|�jrV|�|�j��|�j�|�\}}}|}d}d}|dkr�d}nd}t� d�}t� |��t ���} t���} t� ��}t���}zt�|�j} W�n�ttfy����|} Y�n0�zt�|�j}W�n�tttf�y���|}Y�n0�d��}}|�jd��r�zt�|�jd��}W�nR�t�y����zt�t|�jd���}W�n$�tttf�y����t�|�}Y�n0�Y�n0�|j}|j}n"z| }W�n�t�y����Y�n0�|}d��}}|�jd ��rPzt�|�jd ��}W�nV�ttf�y@���zt�t|�jd ���}W�n$�tttf�y:���t�|�}Y�n0�Y�n0�|j}|j}n"z|}W�n�t�yl���Y�n0�|}|� ��D��]�}d}|�!d�d �}t"|�dk�r��qzt"|d��d k�r�t"|d��dk�rʐqzt"|d ��dk�r�qz|d�d�dv�szt#|d�dd�����$d��s�qz|d�d�}|d�dd���}|d�}|d�}t|d��}t%|d �dd�}||�jv��rv|d|�7�}�qz|d�dk�r�|dk�r�|d||f�7�}d}n.|dk�r�d}n|dk�r�d}n|dk�r�d}t"|�d k�r|d�dk�r�d }n|d!k�rd }nd"}|}nd#| �&��v��r"|}nd}t"|�d$k�s@t'�(|��sLt)d%|���tj*�+|�j,t-|dd��} zt�.| �}!W�nF�t�y����d}|�j/�0|��|d&|�7�}|d'||f�7�}Y��qzY�n0�|dk�rt1�2|!j3��sd}|�j/�0|��|d(|�7�}|d)||f�7�}�qz|dk�rNt1�4|!j3��sNd}d}|�j/�0|��|d*|�7�}|d)||f�7�}�qz|dk�r�t1�5|!j3��s�d}|�j/�0|��|d+|�7�}|d)||f�7�}�qzt6d,|��}"t7j7t8�9|d �d-�dd ����}#t8�:|#�;���}$t1�4|!j3��r�|�jj<d.��rT|$|!j=k�rd}|�j/�0|��|d/|�7�}d0|"d1<�n6t1�4|!j3��r�|$|!j=k��r�|d2|�7�}|�j�0|���qzn8|$|!j=k�r�d}|�j/�0|��|d3||$|!j=f�7�}d0|"d1<�t1�4|!j3��r�||!j>k�r�d}|d4|||!j>f�7�}d5|"d<�t1�4|!j3��rt?| |�j@�}%|%|��A|�k�rd}|d6||��A|�|%f�7�}d7|"d<�|dk�r>|�jd8��r�tB|�jd8�t��rH|�jd8�}&n�zt|�jd8�d�}&W�n��t�y��}'�zhztC�D|!|�jd8��}&W�nD�t�y��}'�z*|�jjE|d9tF|'��tG�H��d:��W�Y�d�}'~'n d�}'~'0�0�W�Y�d�}'~'n d�}'~'0�0�n$|dk�r�|��I|d�}&n|��I||�}&|&t1�J|!j3�k�r>d}d;|"d<<�|d=||&t1�J|!j3�f�7�}d��}(})zt�|!jK�j}(W�n�ttf�yv���|!jK})Y�n0�|dk�r�|| k�s�||k�r�t)d>||| f���|(�r�|(|k�r�d}|d?||(|f�7�}d@|"d <�n.|)� r|)|k� rd}|dA||)|f�7�}d@|"d <�d��}*}+zt�|!jL�j}*W�n �tttf� y@���|!jL}+Y�n0�|dk� r|||k� s`||k� r||| v� r|t)dB||| f���|*� r�|*|k� r�d}|dC||*|f�7�}dD|"d <�n.|+� r�|+|k� r�d}|dE||+|f�7�}dD|"d <�|�rz||�j/v� r�|�j/�0|��|dFd�+|"�|f�7�}�qz|�j/� rd}tM||||||dG�S�)HNz-Tz-s�-xr)���r���TF�owner�grouprO�������� ���rP�������zdl-?����zrwxstah-rG���rA����surrogate_or_strict��errorszPath %s is excluded on request r@����/�dz8Path %s incorrectly tagged as "%s", but is a directory. �l�L�-r����?Z rwxrwxrwxzrwx---z rw-rw-rw-�bsd� ���z"ZIP info perm format incorrect, %szPath %s is missing z>%s++++++.?? %s z/File %s already exists, but not as a directory zc%s++++++.?? %s z7Directory %s already exists, but not as a regular file z2Directory %s already exists, but not as a symlink z.%s.......??z %Y%m%d.%H%M%S� keep_newerz!File %s is older, replacing file rF�������z!File %s is newer, excluding file z$File %s differs in mtime (%f vs %f) z#File %s differs in size (%d vs %d) rE���z5File %s differs in CRC32 checksum (0x%08x vs 0x%08x) �crJ���z%s)r����msg� exception�p����z*Path %s differs in permissions (%o vs %o) z/Cannot change ownership of %s to %s, as user %sz8Path %s is owned by user %s, not by user %s as expected �oz6Path %s is owned by uid %s, not by uid %s as expected z5Cannot change group ownership of %s to %s, as user %sz:Path %s is owned by group %s, not by group %s as expected �gz6Path %s is owned by gid %s, not by gid %s as expected z%s %s )� unarchivedrV���rW���rX����cmd�diff)Nr;���r.���r/���r5����extendr7���r4���rQ����osrI����platform�system� getgroups�getuid�getgid�pwd�getpwuid�pw_name� TypeError�KeyError�grp�getgrgid�gr_name� ValueError� OverflowErrorr1����getpwnamrU����pw_uidrb����getgrnam�gr_gidrR���rS����len� frozenset�issubsetr ���r^����ZIP_FILE_MODE_RE�matchr ���r����joinr0���r����lstatr6���rT����stat�S_ISDIR�st_mode�S_ISREG�S_ISLNK�list�datetime�time�strptime�mktimeZ timetupler2����st_mtime�st_sizer���r&���rg���� isinstancer���Z_symbolic_mode_to_octal� fail_jsonr ���� traceback� format_excrM����S_IMODE�st_uid�st_gidr9���),r>���r����rV���rW���rX����old_outr����r����rI���Z systemtype�groups�run_uidZrun_gidZ run_ownerZ run_groupZ fut_ownerZfut_uidZtpwZ fut_groupZfut_gidZtgrrY���ZchangeZpcsZztypeZpermstr�versionZostype�sizer���ZftypeZ file_umaskr0����stZitemizedZ dt_objectZ timestampr���rJ���re���rn����uidro����gidr���r���r���� is_unarchived���s���� $. L ( zZipArchive.is_unarchivedc�����������������C���s����|�j�dg}|�jr|�|�j��|�|�j��|�jr@|�dg|�j���|�jrR|�|�j��|�d|�jg��|�j� |�\}}}t ||||d�S�)Nz-orm���z-d�r����rV���rW���rX���)r,���r3���r����rT���r/���r5���r7���r0���r4���rQ���r9���)r>���r����rV���rW���rX���r���r���r���� unarchive���s���� zZipArchive.unarchivec�������������� ���C���s����g�}|�j�D�]B}zt|�|d�t|d����W�q �tyJ���|�|d���Y�q 0�q |rhddjd�|�d�fS�|�jd|�jg}|�j � |�\}}}|dkr�dS�dd |�j|f�fS�) Nrs���r���Fz7Unable to find required '{missing}' binary in the path.z' or ')�missingz-l�TN�)Command "%s" could not handle archive: %s)r<����setattrr���r����rT����formatr����r,���r/���r4���rQ���)r>���r�����br����rV���rW���rX���r���r���r����can_handle_archive���s���� zZipArchive.can_handle_archiveN)r!���r"���r#���r?���rM���r[���rg����propertyrl���r����r����r����r���r���r���r���r$���.��s��� %��6r$���c�������������������@���s@���e�Zd�Zdd��Zdd��Zedd���Zdd��Zd d ��Zdd��Z d S�)� TgzArchivec�����������������C���s����||�_�||�_||�_|jd�|�_||�_|�jjrD|�jjdd|�jj�d��dd��|�jjd�D��|�_ |�jjd�|�_ d�|�_d�|�_d |�_ g�|�_d�S�) Nr%���Tz>remote module (%s) does not support check mode when using gtar)Zskippedr����c�����������������S���s���g�|�]}|��d���qS�)rw���)�rstrip)�.0r���r���r���r���� <listcomp>���r���z'TgzArchive.__init__.<locals>.<listcomp>r'���r(���z-z)r/���r0���r1���r2���r3���r4���� check_mode� exit_json�_namer5���r7���r,����tar_type�zipflagr8���r=���r���r���r���r?������s����zTgzArchive.__init__c�����������������C���sJ���|�j�dg}|�j�|�\}}}d�}|�d�r0d}n|�d�rFd|v�rFd}|S�)Nz --versionZbsdtarr}����tarZGNU�gnu)r,���r4���rQ���r_���)r>���r����rV���rW���rX���r����r���r���r���� _get_tar_type���s���� zTgzArchive._get_tar_typec����������� ��� ���C���sJ��|�j�r|�j�S�|�jdd|�jg}|�jr.|�|�j��|�jrF|�dg|�j���|�jrb|�dd��|�jD����|�d|�jg��|�j r�|�|�j ��t |�j�}|�jj||�jt ||||d�d�\}}}|d kr�td |���|���D�]r}tt�|�d ��}|�d�r�|dd���}d }|�j�r.|�jD�]}t�||��rd}��q.�q|s�|�j��t|���q�|�j�S�)Nz--list�-C�--show-transformed-namesc�����������������S���s���g�|�]}d�|��qS��z --exclude=r����r����r���r���r���r���r������r���z/TgzArchive.files_in_archive.<locals>.<listcomp>�-f��LANG�LC_ALL�LC_MESSAGES�LANGUAGE��cwdZenviron_updater���rh���rw���rs���FT)r8���r,���r0���r����rT���r3���r����r5���r/���r7���r ���r4���rQ���r9���r ���rR���r ����codecs� escape_decoder_���ri���) r>���r�����localerV���rW���rX���ra���rk���r'���r���r���r���rl��� ��s:���� & zTgzArchive.files_in_archivec����������� ��� ���C���s:��|�j�dd|�jg}|�jr"|�|�j��|�jr:|�dg|�j���|�jd�r\|�dt|�jd�����|�jd�r~|�dt|�jd�����|�jj d�r�|�d ��|�j r�|�d d��|�j D����|�d|�jg��|�jr�|�|�j��t |�j�}|�jj||�jt||||d �d�\}}}d}|}d}t���}|���|����D�]�} t�| ��r:�q&|dk�rh|�jd��sht�| ��rh|| d�7�}|dk�r�|�jd��s�t�| ��r�|| d�7�}|�jd��s�t�| ��r�|| d�7�}t�| ��r�|| d�7�}t�| ��r�|| d�7�}t�| ��r|| d�7�}t�| ��r&|| d�7�}�q&|�r(d}t|||||d�S�)Nz--diffr����r����rn����--owner=ro����--group=r����--keep-newer-filesc�����������������S���s���g�|�]}d�|��qS�r����r���r����r���r���r���r����C��r���z,TgzArchive.is_unarchived.<locals>.<listcomp>r����r����r����Tr)���r���� rJ���F)r����rV���rW���rX���r����)r,���r0���r����rT���r3���r����r1���r���r4���r2���r5���r/���r7���r ���rQ���r9���r����r����rR���� EMPTY_FILE_RE�search� OWNER_DIFF_RE� GROUP_DIFF_RE�MODE_DIFF_RE�MOD_TIME_DIFF_RE�MISSING_FILE_RE�INVALID_OWNER_RE�INVALID_GROUP_RE) r>���r����r����rV���rW���rX���r����r����r����rY���r���r���r���r����6��sT���� &""zTgzArchive.is_unarchivedc�������������� ���C���s��|�j�dd|�jg}|�jr"|�|�j��|�jr:|�dg|�j���|�jd�r\|�dt|�jd�����|�jd�r~|�dt|�jd�����|�jj d�r�|�d ��|�j r�|�d d��|�j D����|�d|�jg��|�jr�|�|�j��t |�j�}|�jj||�jt||||d �d�\}}}t||||d�S�)Nz --extractr����r����rn���r����ro���r����r���r����c�����������������S���s���g�|�]}d�|��qS�r����r���r����r���r���r���r����y��r���z(TgzArchive.unarchive.<locals>.<listcomp>r����r����r����r����)r,���r0���r����rT���r3���r����r1���r���r4���r2���r5���r/���r7���r ���rQ���r9���)r>���r����r����rV���rW���rX���r���r���r���r����l��s&���� &zTgzArchive.unarchivec�����������������C���s����zt�d�|�_W�n8�tyF���zt�d�|�_W�n�ty@���Y�Y�dS�0�Y�n0�|����|�_|�jdkrpdd|�j|�jf�fS�z|�jr~W�dS�W�n:�ty��}�z"dd|�jt|�f�fW��Y�d�}~S�d�}~0�0�dd |�j�fS�) NZgtarr����)Fz:Unable to find required 'gtar' or 'tar' binary in the pathr����Fz7Command "%s" detected as tar type %s. GNU tar required.r����r����zNCommand "%s" found no files in archive. Empty archive files are not supported.)r���r,���r����r����r����rl���r ���r ���)r>���re���r���r���r���r�������s ���� ,zTgzArchive.can_handle_archiveN) r!���r"���r#���r?���r����r����rl���r����r����r����r���r���r���r���r�������s��� +6r����c�����������������������s���e�Zd�Z��fdd�Z���ZS�)� TarArchivec��������������������s ���t�t|���||||��d|�_d�S�)Nr)���)�superr����r?���r����r=����� __class__r���r���r?������s����zTarArchive.__init__�r!���r"���r#���r?���� __classcell__r���r���r����r���r�������s���r����c�����������������������s���e�Zd�Z��fdd�Z���ZS�)�TarBzipArchivec��������������������s ���t�t|���||||��d|�_d�S�)Nz-j)r����r����r?���r����r=���r����r���r���r?������s����zTarBzipArchive.__init__r����r���r���r����r���r�������s���r����c�����������������������s���e�Zd�Z��fdd�Z���ZS�)�TarXzArchivec��������������������s ���t�t|���||||��d|�_d�S�)Nz-J)r����r����r?���r����r=���r����r���r���r?������s����zTarXzArchive.__init__r����r���r���r����r���r�������s���r����c�����������������������s���e�Zd�Z��fdd�Z���ZS�)�TarZstdArchivec��������������������s ���t�t|���||||��d|�_d�S�)Nz--use-compress-program=zstd)r����r����r?���r����r=���r����r���r���r?������s����zTarZstdArchive.__init__r����r���r���r����r���r�������s���r����c�����������������������s(���e�Zd�Z��fdd�Z��fdd�Z���ZS�)�ZipZArchivec��������������������s&���t�t|���||||��d|�_d|�_d�S�)Nz-Z)r*���)r+���r.���)r����r����r?���r;���r<���r=���r����r���r���r?������s����zZipZArchive.__init__c��������������������sX���t�t|�����\}}|s||fS�|�j|�jg}|�j�|�\}}}d|���v�rLdS�dd|�fS�)Nr-���r����Fz/Command "unzip -Z" could not handle archive: %s)r����r����r����r.���r;���r4���rQ���r^���)r>���Zunzip_availableZ error_msgr����rV���rW���rX���r����r���r���r�������s����zZipZArchive.can_handle_archive)r!���r"���r#���r?���r����r����r���r���r����r���r�������s���r����c�����������������C���st���t�ttttttg}t��}|D�]4}||�|||�}|���\}} |rF|��S�|� | ��qd� |�} |jd|�| f�d��d�S�)Nr����zdFailed to find handler for "%s". Make sure the required command to extract the file is installed. %s�r����)r$���r����r����r����r����r����r�����setr�����addr����r����)r/����destr1���r4����handlersZreasons�handler�objZ can_handle�reasonZ reason_msgr���r���r����pick_handler���s���� r��c������������������C���s,��t�ttddd�tddd�tddd�tdd�tddd�tddd�tdd g�d �tdd g�d �tdd g�d �tddd�tddd�tddd�tddd�d � dddgd�}�|�jd�}|�jd�}t|dd�}|�jd�}|��|�j�}tj�|��s|s�|�jd|�d��n&d|v��rt |�|�}n|�jd|�d��t� |tj��s<|�jd|�d��z&tj�|�dk�r`|�jd|�d��W�n>�t �y��}�z$|�jd|t|�f�d��W�Y�d�}~n d�}~0�0�tj�|��s�|�jd|�d��t||||��}t|jj||d�}|���} |�j�r�| d��|d <�n�| d��rd|d <�nxz>|���|d!<�|d!�d"�dk�rP|�jf�d#d$||f�i|���W�n0�t�y����|�jf�d#d$||f�i|���Y�n 0�d|d <�| �d%d��r�d&| d%�i|d%<�|�d%d��r|�j�sg�} |jD�]�}tj�|t|dd��|d<�z|�j||d �dd'�|d <�W�nF�ttf�yJ�}�z(|�jf�d#d(t|��i|���W�Y�d�}~n d�}~0�0�d)|v��r�|�d)�d�}|| v�r�| �|���q�| �r| D�]z} d*|| f�|d<�z|�j||d �dd'�|d <�W�nF�ttf�y��}�z(|�jf�d#d(t|��i|���W�Y�d�}~n d�}~0�0��q�|�jd+��r|j|d,<�|�jf�i�|���d�S�)-Nr���T)�type�required�boolF)r���default)r��r�����str)r���elementsr��rU���i���) r/���r��� remote_srcZcreates� list_filesr���r'���r(���r%���Zvalidate_certsr&����copyZdecrypt)r(���r'���)Z argument_specZadd_file_common_argsZsupports_check_modeZmutually_exclusiver/���r��rt���ru���r��zSource '%s' failed to transferr����z://zSource '%s' does not existzSource '%s' not readabler���z)Invalid archive '%s', the file is 0 byteszSource '%s' not readable, %sz#Destination '%s' is not a directory)r��r��r/���r����ZchangedZextract_resultsrV���r����zfailed to unpack %s to %sr����Zprepared)�expandz1Unexpected error when accessing exploded file: %srw���z%s/%sr���files)r���r9���r2���r���Zload_file_common_argumentsr����r����existsr����r����access�R_OK�getsizerb���r ����isdirr��r����r!���r����r����r�����IOError�getrl���r����Zset_fs_attributes_if_different�OSErrorrS���rT���r����)r4���r/���r��r0���r��r1���re���r��Zres_argsZ check_resultsZtop_foldersra���Ztop_folder_pathr���r���r���r����main���s����� �� . " 2 6 r���__main__)CZ __future__r���r���r���r��Z __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNr���r����r����ri���r����r����r����r����r���r����r����r����� functoolsr����zipfiler���r���Zansible.module_utils._textr���r ���r ���Zansible.module_utils.basicr���Z#ansible.module_utils.common.processr���Z"ansible.module_utils.common.localer ���Zansible.module_utils.urlsr���Zshlexr����ImportErrorZpipes�compiler����r����r����r����r����r����r����r����r����r���r���rb���r ����objectr$���r����r����r����r����r����r����r��r��r!���r���r���r���r����<module> ���sn����< ���D�. w