
    Pi	                    z    d Z ddlmZ ddlmZmZ g dZ eh d          Z eh d          Z	ddZ
ddZddZdS )z
7z archive command handler for Dippy.

Handles unzip, 7z, 7za, 7zr, 7zz commands.
Read-only operations (list, test, info) are safe, extraction/modification is not.
    )annotations)ClassificationHandlerContext)unzip7z7za7zr7zz>   -Z-l-t-v-z-hh-h--help>   bhilttokens	list[str]returnboolc                4   | dd         D ]t           v r dS                     d          rh                    d          sSt                    dk    r@dd         D ]5}d| t           v s|dv r#t          fddD                       r  d	S   dS 6d	S )
z6Check if unzip command is safe (listing/testing only).   NT-z--lvtZzc              3      K   | ]}|v V  	d S )N ).0cr   s     -/root/projects/gits/Dippy/src/dippy/cli/7z.py	<genexpr>z_check_unzip.<locals>.<genexpr>2   s'      00a16000000    odF)UNZIP_SAFE_FLAGS
startswithlenany)r   charr   s     @r$   _check_unzipr-   (   s    ABBZ 
  
    44<< 	 Q\\$%7%7 	 CFFQJJ!""    t::!111TW__0000400000 %$uuu444	 6E
 5r&   c                b    t          |           dk     rdS | d         dv rdS | d         t          v S )z<Check if 7z command is safe (list/test/hash/benchmark/info).   Tr   )r   r   )r*   SAFE_7Z_COMMANDS)r   s    r$   	_check_7zr1   8   s;    
6{{Qtay$$$t!9(((r&   ctxr   r   c                0   | j         }|st          dd          S |d         }|dk    rt          |          }|r| dn| d}n>|dv r3t          |          }t	          |          d	k    r| d
|d	          }n
|}nd}| d}t          |rdnd|          S )zClassify archive command.askarchive)descriptionr   r   z listz extract)r   r   r	   r
   r    Fallow)r   r   r-   r1   r*   )r2   r   cmdsafedescs        r$   classifyr<   C   s    ZF <e;;;;
)C
g~~F## $:#}}}}S*:*:*:	+	+	+  v;;??''F1I''DDDDT4''u$GGGGr&   N)r   r   r   r   )r2   r   r   r   )__doc__
__future__r   	dippy.clir   r   COMMANDS	frozensetr(   r0   r-   r1   r<   r!   r&   r$   <module>rB      s     # " " " " " 4 4 4 4 4 4 4 4/// 9	 	 	   9        ) ) ) )H H H H H Hr&   