
    Pi	                    N    d Z ddlmZ ddlmZmZ g dZdd	ZddZddZ	ddZ
dS )a	  
Binhex/applesingle/macbinary command handler for Dippy.

macOS file encoding utilities (all implemented as one tool).
- probe: check file encoding (safe)
- encode/decode: convert files (writes output)
- -c/--pipe: use stdin/stdout (safe)
- -o: specify output file
    )annotations)ClassificationHandlerContext)binhexapplesingle	macbinarytokens	list[str]returnboolc                    | D ]	}|dv r dS 
dS )z/Check if -c/--pipe/--to-stdout flag is present.>   -c--pipe--to-stdout--from-stdinTF )r	   ts     1/root/projects/gits/Dippy/src/dippy/cli/binhex.py_has_pipe_flagr      s/      ???44 @5    
str | Nonec                ~    t          |           D ],\  }}|dv r#|dz   t          |           k     r| |dz            c S -dS )z.Extract the output file from -o/--rename flag.>   -o--rename   N	enumeratelenr	   ir   s      r   _extract_output_filer!      sW    &!! ! !1"""q1us6{{':':!a%=   4r   c                ~    t          |           D ],\  }}|dv r#|dz   t          |           k     r| |dz            c S -dS )z6Extract the output directory from -C/--directory flag.>   -C--directoryr   Nr   r   s      r   _extract_output_dirr%   "   sW    &!! ! !1%%%!a%#f++*=*=!a%=   4r   ctxr   r   c                0   | j         }|r|d         nd}d|v sd|v sd|v sd|v rt          d|          S t          |          d	k    r |d	         d
k    rt          d| d          S t          |          rt          d|          S t	          |          }|rt          d||f          S t          |          }|rt          d|          S t          |          d	k    r&|d	         dv rt          d| d|d	                    S t          d|          S )z.Classify binhex/applesingle/macbinary command.r   r   z-hz--helpz-Vz	--versionallow)descriptionr   probez probe)r)   redirect_targetsask>   decodeencode )r	   r   r   r   r!   r%   )r&   r	   baseoutput_file
output_dirs        r   classifyr3   *   sd   ZF,6!99HDv~~V++tv~~PVAVAVg48888
6{{Q6!9//gd???CCCCf 9g48888&v..K 
)^
 
 
 	
 %V,,J 7e6666
6{{Q6!9(<<<eD1F1F6!91F1FGGGG%T2222r   N)r	   r
   r   r   )r	   r
   r   r   )r&   r   r   r   )__doc__
__future__r   	dippy.clir   r   COMMANDSr   r!   r%   r3   r   r   r   <module>r8      s     # " " " " " 4 4 4 4 4 4 4 4111         3 3 3 3 3 3r   