o
    >e                     @   s$  U d dl Z d dlZd dlmZ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 d dlmZmZ d dlmZmZ d	gZe ejd
edejdde ddeddejddddeddejddeddejdejfddZdee defddZeZ ej!e"d	< dS )     N)IterableOptional)__version__)
CLIContext)CLIRootConfigparse_cli_config) SIGNING_PLUGIN_ENTRY_POINT_GROUPSIGNING_PLUGIN_REGISTRY)DEFAULT_CONFIG_FILElogging_setup)	LogConfigparse_logging_configcli_rootpyHanko)	prog_nameversionz--configz.YAML file to load configuration from[default: ]Fr)helprequiredtypez	--verbosezRun in verbose modeT)r   r   defaultr   is_flagz--no-pluginsz"Disable non-builtin plugin loading)r   r   r   ctxc              
   C   s  d }|d u rEzt td}| }W d    n1 sw   Y  t}W n> ty,   Y n6 tyD } ztdt dt| d }~ww z| }W n tya } z
tdt| d }~ww | t	 | j
}d }|d ur|t|}|j|_|j}	nti }	ddlm}
 t|| d}|
| |r|	d  }ttj|jd|	d < n|	d  j}ttj|d|	d	< d
|	vrttj|d|	d
< t|	| |rtd |d urtd| d d S td d S )Nr   zFailed to read z: zFailed to read configuration:    )register)plugins_enabled)leveloutputzpyhanko_certvalidator.fetcherszfontTools.subsetzRunning with --verbosez$Finished reading configuration from .z$There was no configuration to parse.)openr
   readFileNotFoundErrorIOErrorclickClickExceptionstrensure_objectr   objr   config
log_configr   commands.signingr   _load_pluginsr   loggingDEBUGr   WARNINGr   debug)r   r)   verbose
no_pluginsconfig_textfectx_objcfgr*   r   plugins_to_registerroot_logger_config
log_output r;   R/var/www/html/humari/django-venv/lib/python3.10/site-packages/pyhanko/cli/_root.py_root   sj   






r=   root_configr   c           
   	      s  dd l }ddlm  g d}g }|r4| d ur |dd | jD 7 }|jdk r.  tg }n jtd} fdd|D }tt	}t
d	d
 t	D }t||D ]/}| }	t|	tspttjd|j dt|	 ddd qP|	|vr||	 ||	  qP|S )Nr   metadata)z4pyhanko.cli.commands.signing.pkcs11_cli:PKCS11Pluginz2pyhanko.cli.commands.signing.pkcs11_cli:BEIDPluginz0pyhanko.cli.commands.signing.simple:PKCS12Pluginz0pyhanko.cli.commands.signing.simple:PemderPluginc                 S   s   g | ]}t |qS r;   )r&   ).0modr;   r;   r<   
<listcomp>   s    z!_load_plugins.<locals>.<listcomp>)   
   )groupc                    s   g | ]
} j d |tdqS ) )namevaluerF   )
EntryPointr   )rA   vr?   r;   r<   rC      s    c                 s   s    | ]}t |V  qd S )N)r   )rA   xr;   r;   r<   	<genexpr>   s    z _load_plugins.<locals>.<genexpr>zTPlugins must be defined as references to classes with a nullary init function, but 'z' is a z. Disregarding...T)bold)sys	importlibr@   plugin_endpointsversion_infoentry_pointsgetr   listr	   set	itertoolschainload
isinstancer   r$   echostylerI   addappend)
r>   r   rO   to_loadeps_from_metadatato_load_as_endpointsresulting_pluginsseenep
plugin_clsr;   r?   r<   r,   q   sL   



r,   )#rW   r-   typingr   r   r$   pyhankor   pyhanko.cli._ctxr   pyhanko.cli.configr   r   pyhanko.cli.plugin_apir   r	   pyhanko.cli.runtimer
   r   pyhanko.config.loggingr   r   __all__rF   version_optionoptionFileboolpass_contextContextr=   r,   r   Group__annotations__r;   r;   r;   r<   <module>   sN   
 	C8