
    i$                         S r SSKrSSKrSSKrSSKrSSKJrJr   SSK	J
r
   " S S5      rS r\S	:X  a  \" 5         gg! \ a    S r
 N'f = f)
z,
Viewer for PyInstaller-generated archives.
    N)CArchiveReaderZlibArchiveReader)autocompletec                     g N )parsers    VC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller/utils/cliutils/archive_viewer.pyr   r      s        c                   R    \ rS rSrS rS rS rS rS rS r	SS	 jr
SS
 jrS rSrg)ArchiveViewer   c                 t    Xl         X l        X0l        X@l        / U l        U R                  (       a  SU l        g g )NF)filenameinteractive_moderecursive_mode
brief_modestack)selfr   r   r   r   s        r
   __init__ArchiveViewer.__init__   s7      0,$
 $)D! r   c                    U R                  U R                  5      n[        R                  R	                  U R                  5      nU R
                  R                  X!45        U R                  (       d  U R                  5       $ U R                  X!5          [        S5      R                  S S5      nU(       d  U R!                  5         M6  US   R#                  5       nUS:X  a  g US:X  a  U R%                  5         OkUS:X  a  U R&                  " USS  6   ORUS:X  a  U R(                  " USS  6   O9US	:X  a#  U R
                  S
   u  p!U R                  X!5        OU R!                  5         M  ! [         a    [        [        R                  S9   g f = f)Nz?    filer   QUOXS)_open_toplevel_archiver   ospathbasenamer   appendr   _non_interactive_processing_show_archive_contentsinputsplitEOFErrorprintsysstderr_print_usageupper_move_up_the_stack_open_embedded_archive_extract_file)r   archivearchive_nametokenscommands        r
   mainArchiveViewer.main+   s\   --dmm<ww''6

<12 $$3355 	##L: t**43 !!# Qioo'G#~C'')C++VABZ8C""F12J/C(,

2%++LB!!#9   3::&s   E' '!F
Fc                 N   SnU R                   (       a  U R                   R                  5       u  p#US-  nUS:  a  [        S5        U R                  X#5        U R                  (       d  Mg  [        U[        5      (       a]  UR                  R                  5        H?  u  nGt pVUS:X  d  M   UR                  U5      nU R                   R                  UW45        MA     U R                   (       a  M  g g ! [         a)  n[        SU< SU 3[        R                  S9   S nANdS nAff = f)Nr   r    z Could not open embedded archive : r   )r   popr,   r(   r   
isinstancer   tocitemsopen_embedded_archive	Exceptionr-   r.   r&   )	r   archive_countr5   r4   name_typecodeembedded_archivees	            r
   r'   )ArchiveViewer._non_interactive_processingW   s    jj$(JJNN$4!LQMq b	''>&& '>22,3KK,=,=,?(D.A3e/6/L/LT/R, 

))41A*BC -@ jjj"  ) e!$DTHBqc"RY\YcYcdes   *C11
D$;DD$c                     [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  g )NzU: go up one levelr   z/O <name>: open embedded archive with given namez&X <name>: extract file with given namez-S: list the contents of current archive againzQ: quit)r,   r-   r.   )r   s    r
   r/   ArchiveViewer._print_usageo   sL    "4?cjjQ6SZZH=CJJOicjj)r   c                     [        U R                  5      S:  a=  U R                  R                  5         U R                  S   u  pU R                  X5        g [	        S[
        R                  S9  g )Nr   r!   zAlready in the top archive!r   )lenr   r?   r(   r,   r-   r.   )r   r5   r4   s      r
   r1    ArchiveViewer._move_up_the_stackv   sM    tzz?QJJNN$(JJrN!L''>/cjjAr   c                    [         R                  R                  U5      (       d2  [        SU S3[        R
                  S9  [        R                  " S5        USS  R                  5       S:X  a  [        U5      $ [        U5      $ )NzArchive z does not exist!r   r   z.pyz)
r#   r$   isfiler,   r-   r.   exitlowerr   r   )r   r   s     r
   r"   $ArchiveViewer._open_toplevel_archive~   se    ww~~h''HXJ&67cjjIHHQKBC= F*$X..h''r   Nc                    U(       d  [        S5      nUR                  5       nU(       d  g U R                  S   u  p#[        US5      (       d  [	        S[
        R                  S9  g  UR                  U5      nU R                  R                  X45        U R                  X5        g ! [         a)  n[	        SU< SU 3[
        R                  S9   S nAg S nAff = f)NzOpen name? r!   rC   z+Archive does not support embedded archives!r   r=   r>   )r)   stripr   hasattrr,   r-   r.   rC   rD   r&   r(   )r   r5   rG   parent_archiver4   rJ   s         r
   r2   $ArchiveViewer._open_embedded_archive   s     /L#))+  !JJrN~'>???cjjQ	$::<HG 	

<12##L:  	4\4DBqcJQTQ[Q[\	s   'B& &
C0CCc           	         U(       d  [        S5      nUR                  5       nU R                  S   u  p# [        U[        5      (       a  UR                  U5      nOL[        U[        5      (       a  UR                  USS9nUc  [        S5      eO[        S[        U5       S35      e[        S5      nU(       d  [        [        U5      5        g [        US5       nUR!                  U5        S S S 5        g ! [         a-  n[        SU< S	U< S
U 3[        R                  S9   S nAg S nAff = f! , (       d  f       g = f)NzExtract name? r!   T)rawzEntry has no associated data!zExtraction from archive type z not implemented!z!Failed to extract data for entry z from r>   r   zOutput filename? wb)r)   rX   r   r@   r   extractr   
ValueErrorNotImplementedErrortyperD   r,   r-   r.   repropenwrite)r   rF   r5   r4   datarJ   r   fps           r
   r3   ArchiveViewer._extract_file   s!   )*Dzz| !%

2	'>22t,G%677t6<$%DEE   *,I$w-Xi*jkk ,-$t*h% &%  	5dXVLCSSUVWUXY`c`j`jk	 &%s/   &C6 3C6 C6 D06
D- #D((D-0
D>c                    [        U[        5      (       a  UR                  (       a1  [        SU< S35        UR                   H  n[        SU 35        M     [        SU< S35        U R                  (       a0  UR
                  R                  5        H  n[        SU 35        M     g [        S5        UR
                  R                  5        H)  u  nu  pVpxn	[        SU SU SU SU SU	< SU< 35        M+     g [        U[        5      (       a  [        SU< S35        U R                  (       a0  UR
                  R                  5        H  n[        SU 35        M     g [        S5        UR
                  R                  5        H!  u  nu  pn[        SU	 SU SU SU< 35        M#     g [        SW S	35        [        S
[        U5       S35        g )NzOptions in z (PKG/CArchive): zContents of zE position, length, uncompressed_length, is_compressed, typecode, namez, z (PYZ):z! typecode, position, length, namez
 (unknown)z2FIXME: implement content listing for archive type !)
r@   r   optionsr,   r   rA   keysrB   r   rb   )
r   r5   r4   optionrF   positionlengthuncompressed_lengthis_compressedrH   s
             r
   r(   $ArchiveViewer._show_archive_contents   s   g~..L#33CDE%ooFAfX,' .L 00@AB#KK,,.DAdV*% / ]^^e^i^i^o^o^qZDZ8-@QYAhZr&4G3H=/Y[\d[ggijniqrs _r!233L 089#KK,,.DAdV*% / 9::A++:K:K:M6D68vAhZr(2fXRxHI ;N Lj12FtG}oUVWXr   )r   r   r   r   r   r   )__name__
__module____qualname____firstlineno__r   r8   r'   r/   r1   r"   r2   r3   r(   __static_attributes__r   r   r
   r   r      s3    
**$XD0*B(;6>Yr   r   c            	      @   [         R                  " 5       n U R                  SSSSSSS9  U R                  SS	SSS
SS9  U R                  SSSSSSS9  [        R                  R                  U 5        U R                  SSSS9  [        U 5        U R                  5       n[        R                  R                  X5         [        UR                  UR                  (       + UR                  UR                  S9nUR                  5         g ! [         a    [!        S5      ef = f)Nz-lz--listF
store_truelisting_modez:List the archive contents and exit (default: %(default)s).)defaultactiondesthelpz-rz--recursive	recursivezHRecursively print an archive log (default: %(default)s). Implies --list.z-bz--briefbriefzOWhen displaying archive contents, show only file names. (default: %(default)s).r   pyi_archivezPyInstaller archive to process.)metavarr   )r   r   r   r   zAborted by user.)argparseArgumentParseradd_argumentPyInstallerlog__add_optionsr   
parse_args__process_optionsr   r   r{   r   r   r8   KeyboardInterrupt
SystemExit)r	   argsviewers      r
   runr      s3   $$&F
I   W   ^   OO!!&)
.   DOO%%f3	-]]!%!2!22>>zz	
 	 -+,,-s   =A	D D__main__)__doc__r   r#   r-   PyInstaller.logr   PyInstaller.archive.readersr   r   argcompleter   ImportErrorr   r   rt   r   r   r
   <module>r      sc     	 
  I(|Y |Y~.-b zE m  s   > 	A
	A
