o
    `jP                     @   s`   d dl Z d dlZ dddZdd Zdd Zd	d
 Zdd Zdd Zdd Zdd Z	dddZ
dS )    NTc                 C   sl   |  d}|jddtd|dd |jddtd	d
d |jddtddd |jddtd |jddtd d S )N
connectionz-bz--bootstrap-serversappendzGhost:port for cluster bootstrap server. Can be provided multiple times.)typeactionrequiredhelpz-Sz--security-protocol	PLAINTEXTz(PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSLr   defaultr   z-Mz--sasl-mechanismPLAINz8PLAIN, GSSAPI, OAUTHBEARER, SCRAM-SHA-256, SCRAM-SHA-512z-Uz--sasl-user)r   z-Pz--sasl-passwordadd_argument_groupadd_argumentstr)parserbootstrap_requiredconnect_group r   N/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/kafka/cli/common.pyadd_connect_cli_args   s"   




r   c              	   C   st   i }| pg D ]1}| d\}}zt|}W n	 ty   Y nw |dkr&d }n|dkr-d}n|dkr3d}|||< q|S )N=NoneFalseFTrueT)splitint
ValueError)propskwargspropkvr   r   r   build_kwargs   s    
r"   c                 C   sd   | j stdg }| j D ]}|dd |dD  qt| j}||| j| j| j	| j
d |S )NzTpython -m kafka: error: the following arguments are required: -b/--bootstrap-serversc                 s   s     | ]}|  r|  V  qd S N)strip).0sr   r   r   	<genexpr>,   s    z'build_connect_kwargs.<locals>.<genexpr>,)bootstrap_serverssecurity_protocolsasl_mechanismsasl_plain_usernamesasl_plain_password)r)   r   extendr   r"   extra_configupdater*   r+   	sasl_usersasl_password)configr)   entryr   r   r   r   build_connect_kwargs&   s   

r5   c                 C   s   |  d}|jddtddd |jddtd	d
d |jddtd	dd |jdtd dd |jdtd dd |jdtd dd |jdtd dd d S )Nloggingz-lz--log-levelCRITICALz,logging level, passed to logging.basicConfigr	   z-Lz--enable-loggerr   zbenable a specific logger. Can be provided multiple times. If not provided, all loggers are enabledr   r   r   z-Dz--disable-loggerz:disable a specific logger. Can be provided multiple times.z--log-formatz6log message format string, passed to logging.Formatterz--log-date-formatz3log date format string, passed to logging.Formatterz
--log-filez)write logs to this file instead of stderrz--log-configa  path to a logging configuration file for full control over handlers, formatters, etc. A .json (or .yaml/.yml, if PyYAML is installed) file is loaded as a logging.config.dictConfig; any other extension is loaded as a logging.config.fileConfig. The file owns handlers/formatters, so --log-format, --log-date-format and --log-file are ignored, but --enable-logger and --disable-logger still apply as logger level adjustments.r   )r   logging_groupr   r   r   add_logging_cli_args8   s:   

r:   c                 C   s"   |  d}|jddtddd d S )Nextendedz-Cz--extra-configr   zcadditional configuration properties for client in "key=val" format. Can be provided multiple times.r8   r   )r   extended_groupr   r   r   add_extended_cli_argsV   s
   

r=   c                 C   s   |  dr8zddl}W n ty   td| f w t| }t|| W d   dS 1 s1w   Y  dS |  dr_ddl}t| }t|| W d   dS 1 sXw   Y  dS t	j
j| dd dS )zLConfigure logging from a dictConfig (.json/.yaml) or fileConfig (.ini) file.)z.yamlz.ymlr   Nz4PyYAML is required to load a YAML logging config: %sz.jsonF)disable_existing_loggers)endswithyamlImportErrorr   open_dict_config	safe_loadjsonloadr6   r3   
fileConfig)pathr@   frE   r   r   r   _load_log_config]   s   

"

"rJ   c                 C   s   |  dd tj|  d S )Nr>   F)
setdefaultr6   r3   
dictConfig)cfgr   r   r   rC   q   s   rC   c                 C   s:  ddddddd}|| j   }t| dd r>t| j | jd ur=t tj	d	  | jD ]}t|}d
|_
|| q-nJ| jpCtj}| jd ur}| jrSt| j}nt }|| |tj|| jd | jD ]}t|}|| || qjntj||| j| jd | jpg D ]}t|tj	d	  qd S )Nr   
         (   2   )NOTSETDEBUGINFOWARNINGERRORr7   
log_config   F)datefmt)levelformatrZ   filename)	log_leveluppergetattrrJ   rX   enable_loggerr6   	getLoggersetLevelr7   disabled
log_formatBASIC_FORMATlog_fileFileHandlerStreamHandlersetFormatter	Formatterlog_date_format
addHandlerbasicConfigdisable_logger)r3   _LOGGING_LEVELSr^   nameloggerre   handlerr   r   r   configure_loggingy   sH   








rt   c                 C   s   t | | t|  t|  d S r#   )r   r:   r=   )r   r   r   r   r   add_common_cli_args   s   
ru   )T)r6   logging.configr   r"   r5   r:   r=   rJ   rC   rt   ru   r   r   r   r   <module>   s    
-