
    l0j[                        d Z ddlmZ ddlZddlZddlZ	 ddlmZ n$# e$ r 	 ddl	mZ n# e$ r	 ddlmZ Y nw xY wY nw xY wddd
Z
edk    r ej         e
                       dS dS )=Print or replace ImageDescription in first page of TIFF file.    )annotationsN   )tiffcommentargvlist[str] | Nonereturnintc                Z   t          j        dddt           j                  }|                    dddd	           |                                }|                    d
ddd           |                    ddt          j        d          dd           |                    ddt          dd           |                    dddd           |                    | dn	| dd                   }|j        9|j        5  |j        	                                }ddd           n# 1 swxY w Y   nJ|j
        A	 |j
                            d          }n'# t          $ r |                    d           Y nw xY wd}|j        }|@t          j        t"                    5  t          |          }ddd           n# 1 swxY w Y   d}|j        D ]}	 t'          |||j        |           }|rt+          |t,                    r|                    d!"          }t1          |j                  dk    rt3          d#|            t3          |           t1          |j                  dk    rt3                       # t4          $ r,}	t3          | d$|	 t6          j        %           d}Y d}	~	d}	~	ww xY w|S )&z-Tiffcomment command line usage main function.r   r   zExample: tiffcomment --set "my description" image.tif
When multiple files are given with --set or --set-file, the same comment is written to all of them.)progdescriptionepilogformatter_classfiles+filezTIFF file(s) to read or modify)nargsmetavarhelpz--setcommentzreplacement comment string)destr   r   z
--set-filecomment_filerbz2path to a file whose raw bytes replace the comment)r   typer   r   z--page	pageindexNz,index of page to read or modify (default: 0)z--tagtagcodecodez>tag code or name to read or modify (default: ImageDescription)Nr   asciizMcomment contains non-ASCII characters; use --set-file with a pre-encoded filer   )r   r   replace)errorsz# z: )r   )argparseArgumentParserRawDescriptionHelpFormatteradd_argumentadd_mutually_exclusive_groupFileTyper
   
parse_argsr   readr   encodeUnicodeEncodeErrorerrorr   
contextlibsuppress
ValueErrorr   r   r   
isinstancebytesdecodelenprint	Exceptionsysstderr)
r   parsercomment_groupargsr   r   retr   resultexcs
             W/home/wildlama/miniconda3/envs/lam/lib/python3.11/site-packages/tifffile/tiffcomment.pymainr?      s   $K; !<  F -	     7799M)	     t$$A     ;     M	     T\TTtABBx@@D $ 	/ 	/',,..G	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/		!	l))'22GG! 	 	 	LL:    	  $G ,, 	# 	#'llG	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# C
  	 g  F  fe,, =#]])]<<Ftz??Q&&+t++&&&ftz??Q&&GGG  	 	 	T""S""4444CCCCCC	 JsN   <D""D&)D&6E E32E3F66F:=F:I22
J(<"J##J(__main__)N)r   r   r	   r
   )__doc__
__future__r   r"   r-   r6   tifffiler   ImportErrortifffile.tifffiler?   __name__exit     r>   <module>rJ      s   D C " " " " " "      



)%%%%%%% ) ) ))1111111 ) ) )(((((((())X X X X Xv zCHTTVV s$    >*>8>8>>