o
    >e
                     @   sV  d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZmZ d dlmZ d dlmZmZmZ d	d
gZde dZdejdedefdd
Zejdd	dejdedejdejddddejdedejdedejdddedejddded dd!ejd"d#dedejdededededed$ed%efd&d	ZdS )'    )OptionalN)cli_root)	CLIConfig)DEFAULT_CONFIG_FILEpyhanko_exception_manager)_index_pageloggerreadable_file)ConfigurationError)QRStampStyleqr_stamp_filetext_stamp_filestampselect_stylez2Using stamp styles requires a configuration file (z by default).ctx
style_nameurlc              
   C   s   | j j}|s|s
d S ttz||}W n ty0 } ztj|j	|d t|j	d }~ww |r=t
|ts=td|sIt
|trItd|S )N)exc_infozAThe --stamp-url parameter is only meaningful for QR stamp styles.z/QR stamp styles require the --stamp-url option.)objconfigclickClickException_CONFIG_REQUIRED_MSGget_stamp_styler
   r   errormsg
isinstancer   )r   r   r   
cli_configstylee r    [/var/www/html/humari/django-venv/lib/python3.10/site-packages/pyhanko/cli/commands/stamp.pyr      s*   
zstamp PDF files)helpnameinfile)typeoutfileTF)writabledir_okayxyz--style-namez%stamp style name for stamp appearance)r"   requiredr%   z--pagez)page on which the stamp should be applied   )r"   r+   r%   defaultshow_defaultz--stamp-urlz$QR code URL to use in QR stamp stylepage	stamp_urlc              
   C   s   | j j}|d u rttt 3 t| ||}	t|}
|r)t|||	|
|||d nt	|||	|
||d W d    d S W d    d S 1 sFw   Y  d S )N)	dest_pager)   r*   r   )r1   r)   r*   )
r   r   r   r   r   r   r   r   r   r   )r   r$   r&   r)   r*   r   r/   r0   r   stamp_stylepage_ixr    r    r!   r   .   s,   $

") typingr   r   pyhanko.cli._rootr   pyhanko.cli.configr   pyhanko.cli.runtimer   r   pyhanko.cli.utilsr   r   r	   pyhanko.config.errorsr
   pyhanko.stampr   r   r   __all__r   Contextstrr   commandargumentPathintoptionpass_contextr   r    r    r    r!   <module>   sn     