
    Pi|                        d Z ddlmZ ddlmZmZ dgZ eh d          Z eh d          Z	ddZ
ddZddZddZdS )aF  
Sips command handler for Dippy.

macOS scriptable image processing system.
- -g/--getProperty, --verify are safe read operations
- Most other flags modify images: -s, -d, -e, -r, -f, -c, -p, -z, -Z, -i, etc.
- -o/--out specifies output file for modifications
- -x/--extractProfile extracts embedded profile to specified file
    )annotations)ClassificationHandlerContextsips>   -1-h--help--verify	--oneLine-g--getProperty>'   -E-M-X-Z-c-d-e-f-m-p-r-s-z--flip--rotate	--copyTag	--loadTag	--matchTo
--padColor--deleteTag--cropOffset--extractTag--setProperty--embedProfile--resampleWidth--deleteProperty--resampleHeight--padToHeightWidth--cropToHeightWidth--matchToWithIntent--embedProfileIfNone--resampleHeightWidth--resampleHeightWidthMaxr   -o-x--outr   --extractProfiletokens	list[str]return
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/--out flag.>   r/   r1      N	enumeratelenr3   its      //root/projects/gits/Dippy/src/dippy/cli/sips.py_extract_output_filer@   D   sV    &!! ! !1AECKK$7$7!a%=   4    c                ~    t          |           D ],\  }}|dv r#|dz   t          |           k     r| |dz            c S -dS )z7Extract the profile file from -x/--extractProfile flag.>   r0   r2   r8   Nr9   r<   s      r?   _extract_profile_filerC   L   sW    &!! ! !1***q1us6{{/B/B!a%=   4rA   boolc                    d}d}|t          |           k     rM| |         }|                    d          r|t          v rd}|dv r|dz  }EndS |dz  }|t          |           k     M|pt          |           dk    S )z+Check if command only uses read-only flags.r8   F-T>   r   r      )r;   
startswith
SAFE_FLAGS)r3   r=   has_operationr>   s       r?   _is_read_onlyrK   T   s    	AM
c&kk//1I<< 		J $///FA 0
 u	Q c&kk// ,CKK1,,rA   ctxr   r   c                   | j         }t          |          rt          dd          S t          |          }|rt          dd|f          S t	          |          }|rt          dd|f          S t          dd          S )zClassify sips command.allowr   )descriptionzsips -x)rO   redirect_targetsask)r3   rK   r   rC   r@   )rL   r3   profile_fileoutput_files       r?   classifyrT   h   s    ZFV ;g6::::(00L 
!*_
 
 
 	
 'v..K 
)^
 
 
 	
 %V4444rA   N)r3   r4   r5   r6   )r3   r4   r5   rD   )rL   r   r5   r   )__doc__
__future__r   	dippy.clir   r   COMMANDS	frozensetrI   FLAGS_WITH_ARGr@   rC   rK   rT    rA   r?   <module>r\      s     # " " " " " 4 4 4 4 4 4 4 48 YJJJ 

 ( ( (* *Z      - - - -(5 5 5 5 5 5rA   