
    VhFZ                        d dl mZmZmZ eZdZdZdZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZmZ d dl m!Z! 	 d dlm"Z" dZ%e!jL                  r	 d dl'Z'dZ(n		 d dl)m'Z' dZ(ed d dk\  Z*dZ+dZ,dZ-dZ.d Z/d Z0d Z1d Z2d Z3d Z4d Z5d Z6 e!jn                  e	jp                         G d  d!e9             Z: G d" d#e:      Z; G d$ d%e:      Z<d& Z=d' Z>e?d(k(  r e>        yy# e#$ r	 d dlm$Z" Y w xY w# e#$ r  e       Z%dZ(Y w xY w# e#$ r  e       Z%dZ(Y w xY w))    )absolute_importdivisionprint_functiona'  
module: archive
short_description: Creates a compressed archive of one or more files or trees
extends_documentation_fragment:
  - files
  - community.general.attributes
description:
  - Creates or extends an archive.
  - The source and archive are on the target host, and the archive I(is not) copied to the controller host.
  - Source files can be deleted after archival by specifying O(remove=True).
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  path:
    description:
      - Remote absolute path, glob, or list of paths or globs for the file or files to compress or archive.
    type: list
    elements: path
    required: true
  format:
    description:
      - The type of compression to use.
    type: str
    choices: [bz2, gz, tar, xz, zip]
    default: gz
  dest:
    description:
      - The file name of the destination archive. The parent directory must exists on the remote host.
      - This is required when O(path) refers to multiple files by either specifying a glob, a directory or multiple paths
        in a list.
      - If the destination archive already exists, it will be truncated and overwritten.
    type: path
  exclude_path:
    description:
      - Remote absolute path, glob, or list of paths or globs for the file or files to exclude from O(path) list and glob
        expansion.
      - Use O(exclusion_patterns) to instead exclude files or subdirectories below any of the paths from the O(path) list.
    type: list
    elements: path
    default: []
  exclusion_patterns:
    description:
      - Glob style patterns to exclude files or directories from the resulting archive.
      - This differs from O(exclude_path) which applies only to the source paths from O(path).
    type: list
    elements: path
    version_added: 3.2.0
  force_archive:
    description:
      - Allows you to force the module to treat this as an archive even if only a single file is specified.
      - By default when a single file is specified it is compressed only (not archived).
      - Enable this if you want to use M(ansible.builtin.unarchive) on an archive of a single file created with this module.
    type: bool
    default: false
  remove:
    description:
      - Remove any added source files and trees after adding to archive.
    type: bool
    default: false
notes:
  - Can produce C(gzip), C(bzip2), C(lzma), and C(zip) compressed files or archives.
  - This module uses C(tarfile), C(zipfile), C(gzip), and C(bz2) packages on the target host to create archives. These are
    part of the Python standard library for Python 2 and 3.
requirements:
  - Requires C(lzma) (standard library of Python 3) or L(backports.lzma, https://pypi.org/project/backports.lzma/) (Python
    2) if using C(xz) format.
seealso:
  - module: ansible.builtin.unarchive
author:
  - Ben Doherty (@bendoh)
a  
- name: Compress directory /path/to/foo/ into /path/to/foo.tgz
  community.general.archive:
    path: /path/to/foo
    dest: /path/to/foo.tgz

- name: Compress regular file /path/to/foo into /path/to/foo.gz and remove it
  community.general.archive:
    path: /path/to/foo
    remove: true

- name: Create a zip archive of /path/to/foo
  community.general.archive:
    path: /path/to/foo
    format: zip

- name: Create a bz2 archive of multiple files, rooted at /path
  community.general.archive:
    path:
      - /path/to/foo
      - /path/wong/foo
    dest: /path/file.tar.bz2
    format: bz2

- name: Create a bz2 archive of a globbed path, while excluding specific dirnames
  community.general.archive:
    path:
      - /path/to/foo/*
    dest: /path/file.tar.bz2
    exclude_path:
      - /path/to/foo/bar
      - /path/to/foo/baz
    format: bz2

- name: Create a bz2 archive of a globbed path, while excluding a glob of dirnames
  community.general.archive:
    path:
      - /path/to/foo/*
    dest: /path/file.tar.bz2
    exclude_path:
      - /path/to/foo/ba*
    format: bz2

- name: Use gzip to compress a single archive (i.e don't archive it first with tar)
  community.general.archive:
    path: /path/to/foo/single.file
    dest: /path/file.gz
    format: gz

- name: Create a tar.gz archive of a single file.
  community.general.archive:
    path: /path/to/foo/single.file
    dest: /path/file.tar.gz
    format: gz
    force_archive: true
a  
state:
  description: The state of the input O(path).
  type: str
  returned: always
dest_state:
  description:
    - The state of the O(dest) file.
    - V(absent) when the file does not exist.
    - V(archive) when the file is an archive.
    - V(compress) when the file is compressed, but not an archive.
    - V(incomplete) when the file is an archive, but some files under O(path) were not found.
  type: str
  returned: success
  version_added: 3.4.0
missing:
  description: Any files that were missing from the source.
  type: list
  returned: success
archived:
  description: Any files that were compressed or added to the archive.
  type: list
  returned: success
arcroot:
  description: The archive root.
  type: str
  returned: always
expanded_paths:
  description: The list of matching paths from paths argument.
  type: list
  returned: always
expanded_exclude_paths:
  description: The list of matching exclude paths from the exclude_path argument.
  type: list
  returned: always
Nfnmatch)version_info)
format_exc)crc32)AnsibleModulemissing_required_lib)to_bytes	to_native)six)
BadZipFile)
BadZipfileTF)lzma   )r      absentarchivecompress
incompletec                    | rt        | d   t        j                        rdnd}t        j                  j                  t        j                  j                  t        j                  j                  | D cg c]?  }t        j                  j                  t        j                  j                  |      |      A c}            |      S c c}w )Nr        )
isinstancer   binary_typeospathjoindirnamecommonprefix)pathsemptyps      m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/archive.pycommon_pathr'      s    Za#//BCE77<<
,,_d-eZ[bggll277??1;Mu.U-efgin -es   3ACc                     g }d}| D ]A  }t        |      }d|v sd|v rt        j                  |      }d}n|g}|j                  |       C ||fS )NF   *   ?T)	_to_bytesglobextend)r#   expanded_path	is_globbyr   b_pathe_pathss         r&   expand_pathsr2      sf    MI &46>TV^ii'GIhGW%& )##r   c                 ,     t         fd|D              S )Nc              3   6   K   | ]  }t        |        y wNr   ).0r%   r   s     r&   	<genexpr>z-matches_exclusion_patterns.<locals>.<genexpr>   s     <AwtQ<s   )any)r   exclusion_patternss   ` r&   matches_exclusion_patternsr:      s    <);<<<r   c                     t        j                  dt        j                  j	                  |       t         j
                        S )Ns&   \.(tar|tar\.(gz|bz2|xz)|tgz|tbz2|zip)$)researchr   r   basename
IGNORECASEr   s    r&   
is_archiverA      s-    99?AQAQRVAWY[YfYfggr   c                 D    |j                  |       r|t        |       d  S |S r5   )
startswithlen)prefixstrings     r&   strip_prefixrG     s%    #)#4#4V#<6#f+,H&Hr   c                     t        | d      S Nsurrogate_or_strict)errors)r   ss    r&   r+   r+     s    A344r   c                     t        | d      S rI   r   rL   s    r&   
_to_nativerP     s    Q455r   c                     t        | dd      S )NrJ   ascii)rK   encodingrO   rL   s    r&   _to_native_asciirT     s    Q4wGGr   c                   6   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zed        Zd Zd Zej.                  d        Zej.                  d        Zej.                  d        Zej.                  d        Zej.                  d        Zy)Archivec           	          || _         |j                  d   rt        |j                  d         nd | _        |j                  d   xs g | _        |j                  d   | _        |j                  d   | _        |j                  d   | _        d| _        t        | _
        g | _        d | _        g | _        g | _        g | _        |j                  d   }t!        |      \  | _        }t!        |j                  d         d	   | _        t'        t)        | j"                        t)        | j$                        z
        | _        | j*                  sh|j-                  d
j/                  |      t1        dj/                  | j"                              t1        dj/                  | j$                              d       t3        | j*                        | _        | j                  sSt7        |t8        j:                  j=                  | j*                  d	         t?        | j*                        dkD  g      | _        | j                  s8| j                  s,d| j*                  d	   t        | j
                        fz  | _        | j                  rB| j                  s6|j-                  t1        | j                        d
j/                  |      d       | j                  r| jA                          | jC                         | _"        | jG                         | _$        y )Ndestr9   formatforce_archiveremoveFr   exclude_pathr   z,    , z!Error, no source paths were found)r   expanded_pathsexpanded_exclude_pathsmsg   s   %s.%szAError, must specify "dest" when archiving multiple files or trees)rX   r   r`   )%moduleparamsr+   destinationr9   rY   must_archiver[   changedSTATE_ABSENTdestination_staterK   file	successestargets	not_foundr2   r^   r_   sortedsetr#   	fail_jsonr    rP   r'   rootr8   r   r   isdirrD   _check_removal_safetydestination_checksumsoriginal_checksumsdestination_sizeoriginal_size)selfrb   r#   	has_globss       r&   __init__zArchive.__init__  sb   ?E}}V?T9V]]6%:;Z^"(--0D"E"KmmH-"MM/:mmH-!-	f%)5e)<&Y&26==3P&QRS&T#C 3 34s4;V;V7WWX
zzYYu%)%**T5H5H*IJ'1%**T=X=X2Y'Z7	    

+	   #Ydjjm0LcRVR\R\o`aNa$b cD(9(9'4::a=)DKK:P*QQDT%5%5 0 01YYu%W   ;;&&("&"<"<">!224r   c                 J   	 | j                  t        |      t        |             | j                  t        |            r| j                  j                  |       y y # t        $ r<}| j                  j                  t        |      dt        |             Y d }~y d }~ww xY w)N: )_addrT   rP   containsrj   append	ExceptionrK   )rw   r   archive_namees       r&   addzArchive.addJ  s    	SII&t,j.FG}}Z56%%d+ 7 	SKK+;D+A:a=QRR	Ss   AA 	B"&2BB"c           	         | j                   dv rR| j                          | j                  |t        | j                  |             | j                          t        | _        y 	 | j                  t        | j                        d      }t        |d      5 }t        j                  ||       d d d        |j                          | j                  j                  |       t        | _        y # 1 sw Y   @xY w# t         t"        f$ rY}| j$                  j'                  t)        |      t)        | j                        dt)        |      z  t+                      Y d }~y d }~ww xY w)Nziptarwbrbz&Unable to write to compressed file: %s)r   rX   r`   	exception)rY   openr   rG   rp   closeSTATE_ARCHIVEDrh   _open_compressed_filerT   rd   shutilcopyfileobjrj   r~   STATE_COMPRESSEDIOErrorOSErrorrb   ro   rP   r	   )rw   r   f_outf_inr   s        r&   add_single_targetzArchive.add_single_targetR  s   ;;.(IIKHHT<		489JJL%3D"223CDDTDT3UW[\$% 4&&tU34%%d+)9&	4 4
 W% %%#D)#D$4$45@:a=P\f\h &  s1   "1C5 C)*>C5 )C2.C5 5EAEEc                 8   | j                          	 | j                  D ]  }t        j                  j	                  |      rt        j
                  |d      D ]  \  }}}|D ]H  }t        j                  j                  ||      }| j                  |t        | j                  |             J |D ]H  }t        j                  j                  ||      }| j                  |t        | j                  |             J  | j                  |t        | j                  |              	 | j#                          | j$                  rO| j                  j                  d	t        | j                        dd
j                  | j$                               y y # t        $ r~}| j                  dv r| j                  }	nd| j                  z   }	| j                  j                  d|	dt        | j                        dt        |      t!                      Y d }~d }~ww xY w)NT)topdownr   ztar.zError when writing z archive at r{   r`   r   zErrors when writing archive at z; r`   )r   rk   r   r   rq   walkr    r   rG   rp   r   rY   rb   ro   rP   rd   r	   r   rK   )
rw   targetdirectory_pathdirectory_names
file_namesdirectory_name	full_path	file_namer   archive_formats
             r&   add_targetszArchive.add_targetsg  s   			,, F77==(GIwwv_cGd TC.= TN(*^^(TI HHYTYY	0RST *4 TI(*^Y(OI HHYTYY	0RSTT HHV\$))V%DEF. 	

;;KK!!?I$JZJZ?[]a]f]fgkgrgr]st "    
	{{n,!%!'$++!5KK!!"Jt/?/?$@*Q- %,	 "  
	s   DF 	HA4HHc                     | j                   | j                  | j                         k7  S | j                   | j                         k7  S r5   )rt   rv   ru   rs   rw   s    r&   is_different_from_originalz"Archive.is_different_from_original  sB    ""*%%)>)>)@@@**d.H.H.JJJr   c                 z    | j                         r+| j                         r| j                  | j                        S y r5   )destination_existsdestination_readable_get_checksumsrd   r   s    r&   rs   zArchive.destination_checksums  s3    ""$)B)B)D&&t'7'788r   c                 p    | j                   xr) t        j                  j                  | j                         S r5   )rd   r   r   existsr   s    r&   r   zArchive.destination_exists  s&    DBGGNN43C3C$DDr   c                 z    | j                   xr. t        j                  | j                   t        j                        S r5   )rd   r   accessR_OKr   s    r&   r   zArchive.destination_readable  s(    HBIId.>.>$HHr   c                 x    | j                         r)t        j                  j                  | j                        S dS )Nr   )r   r   r   getsizerd   r   s    r&   ru   zArchive.destination_size  s,    484K4K4Mrwwt//0TSTTr   c                     | j                   D ]X  }t        j                  j                  |      s| j                  j                  |       >| j                  j                  |       Z y r5   )r#   r   r   lexistsrl   r~   rk   rw   r   s     r&   find_targetszArchive.find_targets  sI    JJ 	*D77??4(%%d+##D)		*r   c                 ,    t        | j                        S r5   )boolrk   r   s    r&   has_targetszArchive.has_targets  s    DLL!!r   c                 ,    t        | j                        S r5   )r   rl   r   s    r&   has_unfound_targetszArchive.has_unfound_targets  s    DNN##r   c                     	 t        j                  |       y # t        $ rE}| j                  j	                  t        |      dt        |      z  t                      Y d }~y d }~ww xY w)Nz Unable to remove source file: %s)r   r`   r   )r   r[   r   rb   ro   rP   r	   )rw   r   r   s      r&   remove_single_targetzArchive.remove_single_target  sX    	IIdO 	KK!!%6AFR\R^ "  	s    	A&;A!!A&c                    | j                   D ]m  }t        j                  j                  |      s#	 t        j                  j	                  |      rt        j                  |       nt        j                  |       o | j                  D ]7  }	 t        j                  j	                  |      rt        j                  |       9 | j                  r<| j                  j                  t        | j                        d| j                         y y # t        $ r( | j                  j                  t        |             Y /w xY w# t        $ r' | j                  j                  t        |             Y w xY w)Nz"Error deleting some source files: )rX   r`   files)rj   r   r   r   rq   r   rmtreer[   r   rK   r~   rP   r#   rb   ro   rd   r   s     r&   remove_targetszArchive.remove_targets  s   NN 	9Dww~~d#9ww}}T*d+		$	9 JJ 	5D577==&MM$'	5 ;;KK!! 0 017[cgcncn "    9KK&&z$'789  5"":d#345s$   A
D4E -D=<D= -E0/E0c                     | j                   j                  | j                   j                  | j                        }| j                   j	                  || j
                        | _        y )Nr@   )rb   load_file_common_argumentsrc   rd   set_fs_attributes_if_differentrf   )rw   	file_argss     r&   update_permissionszArchive.update_permissions  sH    KK::4;;;M;MTXTdTd:e	{{AA)T\\Zr   c                    | j                   D cg c]  }t        |       c}t        | j                        | j                  | j                  t        | j
                        | j                  D cg c]  }t        |       c}| j                  D cg c]  }t        |       c}| j                  D cg c]  }t        |       c}dS c c}w c c}w c c}w c c}w )N)archivedrX   
dest_staterf   arcrootmissingr^   r_   )	rj   rP   rd   rh   rf   rp   rl   r^   r_   )rw   r%   s     r&   resultzArchive.result  s     15?1A?t//000||!$)),/3~~>!
1>6:6I6IJz!}J>B>Y>Y&Zz!}&Z	
 		
?
 ?J&Zs   C
/CC3Cc                 F   | j                   D ]  }t        j                  j                  |      s#| j                  j                  t        j                  j                  |d            s]| j                  j                  dj                  | j                         d        y )Nr   r]   zLError, created archive can not be contained in source paths when remove=true)r   r`   )	r#   r   r   rq   rd   rC   r    rb   ro   r   s     r&   rr   zArchive._check_removal_safety  ss    JJ 	Dww}}T"t'7'7'B'B277<<PTVYCZ'[%%DJJ/f & 	r   c                 F   d }| j                   dk(  rt        j                  ||      }|S | j                   dk(  rt        j                  ||      }|S | j                   dk(  rt        j                  ||      }|S | j                  j                  d| j                   z         |S )Ngzbz2xzz%s is not a valid formatr   )	rY   gzipr   r   BZ2Filer   LZMAFilerb   ro   )rw   r   modefs       r&   r   zArchive._open_compressed_file  s    ;;$		$%A  [[E!D$'A  [[D dD)A  KK!!&@4;;&N!Or   c                      y r5    r   s    r&   r   zArchive.close      r   c                      y r5   r   rw   names     r&   r}   zArchive.contains  r   r   c                      y r5   r   r   s    r&   r   zArchive.open  r   r   c                      y r5   r   rw   r   r   s      r&   r|   zArchive._add  r   r   c                      y r5   r   r   s     r&   r   zArchive._get_checksums  r   r   N)__name__
__module____qualname__ry   r   r   r   r   rs   r   r   ru   r   r   r   r   r   r   propertyr   rr   r   abcabstractmethodr   r}   r   r|   r   r   r   r&   rV   rV     s    25hS*BK
EIU*"$,[ 

 

 	  	  	  	  	 r   rV   c                   <     e Zd Z fdZd Zd Zd Zd Zd Z xZ	S )
ZipArchivec                 ,    t         t        |   |       y r5   )superr   ry   rw   rb   	__class__s     r&   ry   zZipArchive.__init__  s    j$(0r   c                 8    | j                   j                          y r5   )ri   r   r   s    r&   r   zZipArchive.close  s    		r   c                 Z    	 | j                   j                  |       y# t        $ r Y yw xY wNFT)ri   getinfoKeyErrorr   s     r&   r}   zZipArchive.contains
  s2    	IId#   		    	**c                     t        j                  t        | j                        dt         j                  d      | _        y )NwT)zipfileZipFilerT   rd   ZIP_DEFLATEDri   r   s    r&   r   zZipArchive.open  s+    OO$4T5E5E$FWMaMacgh	r   c                 j    t        || j                        s| j                  j                  ||       y y r5   )r:   r9   ri   writer   s      r&   r|   zZipArchive._add  s*    )$0G0GHIIOOD,/ Ir   c                     	 t        j                  t        |      d      }t        d |j	                         D              }|j                          |S # t        $ r t               }Y |S w xY w)Nrc              3   L   K   | ]  }|j                   |j                  f  y wr5   )filenameCRCr6   infos     r&   r7   z,ZipArchive._get_checksums.<locals>.<genexpr>  s     U$T]]DHH5U   "$)r   r   rT   rn   infolistr   r   )rw   r   r   	checksumss       r&   r   zZipArchive._get_checksums  se    	oo&6t&<cBGU'BRBRBTUUIMMO   	I	s   AA A*)A*
r   r   r   ry   r   r}   r   r|   r   __classcell__r   s   @r&   r   r     s"    1i0r   r   c                   <     e Zd Z fdZd Zd Zd Zd Zd Z xZ	S )
TarArchivec                 :    t         t        |   |       d | _        y r5   )r   r  ry   fileIOr   s     r&   ry   zTarArchive.__init__#  s    j$(0r   c                 Z   | j                   j                          | j                  dk(  rvt        j                  t        | j                        d      5 }|j                  | j                  j                                d d d        | j                  j                          y y # 1 sw Y   %xY w)Nr   r   )
ri   r   rY   r   r   rP   rd   r   r	  getvalue)rw   r   s     r&   r   zTarArchive.close'  sz    		;;$:d&6&67> 0!,,./0KK 0 0s   *B!!B*c                 Z    	 | j                   j                  |       y# t        $ r Y yw xY wr   )ri   	getmemberr   r   s     r&   r}   zTarArchive.contains.  s2    	II%   		r   c                    | j                   dv r<t        j                  t        | j                        d| j                   z         | _        y | j                   dk(  r@t        j                         | _        t        j                  | j                  d      | _        y | j                   dk(  r/t        j                  t        | j                        d      | _        y | j                  j                  d| j                   z         y )	N)r   r   zw|r   r   )fileobjr   r   z %s is not a valid archive formatr   )rY   tarfiler   rT   rd   ri   ioBytesIOr	  rb   ro   r   s    r&   r   zTarArchive.open5  s    ;;-'%5d6F6F%GPTP[P[I[\DI [[D **,DKT[[sCDI[[E!%5d6F6F%GMDIKK!!&H4;;&V!Wr   c                       fd} fd}t         r  j                  j                  ||d|       y  j                  j                  ||d|       y )Nc                 L    t        | j                  j                        rd S | S r5   )r:   r   r9   )tarinforw   s    r&   py27_filterz$TarArchive._add.<locals>.py27_filterC  s"    5gllDD[D[\4ibiir   c                 0    t        | j                        S r5   )r:   r9   )r   rw   s    r&   py26_filterz$TarArchive._add.<locals>.py26_filterF  s    -dD4K4KLLr   F)	recursivefilter)r  exclude)PY27ri   r   )rw   r   r   r  r  s   `    r&   r|   zTarArchive._addB  sD    	j	M IIMM$kMRIIMM${MSr   c                 p   t         rt        j                  }nt        j                  }	 | j
                  dk(  rpt        j                  t        |      d      5 }t        j                  |      }t        d |j                         D              }|j                          d d d        |S t        j                  t        |      d| j
                  z         }t        d |j                         D              }|j                          	 |S # 1 sw Y   S xY w# |t        j                  t        j                  f$ r} 	 | j                  t        |      d      }d}	 |j                  d      }|snt        ||      }!t        d	|fg      }|j                          Y |S # t        $ r t               }Y Y |S w xY ww xY w)
Nr   r   )r  c              3   L   K   | ]  }|j                   |j                  f  y wr5   r   chksumr   s     r&   r7   z,TarArchive._get_checksums.<locals>.<genexpr>X  s     #^TYY$<#^r   zr|c              3   L   K   | ]  }|j                   |j                  f  y wr5   r  r   s     r&   r7   z,TarArchive._get_checksums.<locals>.<genexpr>\  s     ZTDKK 8Zr   r   i   r   )HAS_LZMAr   	LZMAErrorr  	ReadErrorrY   r   rT   rn   
getmembersr   CompressionErrorr   readr
   r   )rw   r   r#  r   r   r  checksumchunks           r&   r   zTarArchive._get_checksumsN  s   I  ))I	"{{d"YY/5s; $q%ll15G ##^I[I[I]#^ ^IMMO$. % ",,'7'=tdkk?QRZWEWEWEYZZ	  /$.  7,,g.F.FG 	"" ../?/EsKFF#34E $UH5H	 
  #x 12		   "E	"	"sP   .D ADD (AD DD D $F59AFF1,F50F11F5r  r  s   @r&   r  r  "  s#     X
Tr   r  c                 R    | j                   d   dk(  rt        |       S t        |       S )NrY   r   )rc   r   r  )rb   s    r&   get_archiver+  p  s)    }}X%'&!!&!!r   c                     t        t        t        ddd      t        ddg d      t        d	      t        ddg 
      t        dd      t        dd      t        dd            dd      } t        s4| j                  d   dk(  r"| j	                  t        dd      t               | j                  }t        |       }|j                          |j                         s9|j                         r9t        |j                        rt        nt        |_        n|j                         r|j"                  r{|rd|_        n|j'                          |j)                         rt*        nt        |_        |xj$                  |j-                         z  c_        |j.                  r|j1                          nz|r|j                         shd|_        n`|j2                  d   }|j5                  |       |xj$                  |j-                         z  c_        |j.                  r|j7                  |       |j                         r|j9                           | j:                  di |j<                   y )Nlistr   T)typeelementsrequiredstrr   )r   r   r   r   r   )r.  defaultchoices)r.  )r.  r/  r2  )r.  r/  r   F)r.  r2  )r   rY   rX   r\   r9   rZ   r[   )argument_specadd_file_common_argssupports_check_moderY   r   zlzma or backports.lzmazwhen using xz format)reasonr   r   r   )r   dictr"  rc   ro   r   LZMA_IMP_ERR
check_moder+  r   r   r   rA   rd   r   r   rh   re   rf   r   r   STATE_INCOMPLETEr   r[   r   r#   r   r   r   	exit_jsonr   )rb   r:  r   r   s       r&   mainr=  w  s   6FTBUD:[\6"6FBG#&AFE:VU3
 " F h/47$%=F\]iu 	 	
 ""J&!G %%':DWEXEX:Y_oG%				7#7#7"GO!<C<W<W<Y(8_mG%OOwAACCO~~&&(--/"&==#D%%d+OOwAACCO~~,,T2!!#""$F&w~~&r   __main__)@
__future__r   r   r   r.  __metaclass__DOCUMENTATIONEXAMPLESRETURNr   r   r,   r   r  r   r<   r   r  r   r   sysr   	tracebackr	   zlibr
   ansible.module_utils.basicr   r   +ansible.module_utils.common.text.convertersr   r   ansible.module_utilsr   r   ImportErrorr   r9  PY3r   r"  	backportsr  rg   r   r   r;  r'   r2   r:   rA   rG   r+   rP   rT   add_metaclassABCMetaobjectrV   r   r  r+  r=  r   r   r   r&   <module>rP     s   A @IV7r#
J  
   	 	 	         J K $1" 77
"
 AaF"  $=hI56H 3;;kf k  k\ >K K\"3'l zF E  101  !|  !|s6   *D ?D D0 DDD-,D-0E E