o
    þðc¿  ã                
   @   s  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dee	ef d	ee	 d
ee	ef fdd„Z
dee	ef d
eee eee	 ee	ef f fdd„Zdee	ef d
eee	 ee	e	f f fdd„Zdee	ef d
eee	 ee	df eee	ef f fdd„ZdS )zParserNode utilsé    )ÚAny)ÚDict)ÚIterable)ÚOptional)ÚTuple)Ú
ParserNodeÚkwargsÚrequired_namesÚreturnc              	   C   s`   i }|D ]}z	|   |¡||< W q ty   td |¡ƒ‚w | r.d |  ¡ ¡}td |¡ƒ‚|S )aq  
    Ensures that the kwargs dict has all the expected values. This function modifies
    the kwargs dictionary, and hence the returned dictionary should be used instead
    in the caller function instead of the original kwargs.

    :param dict kwargs: Dictionary of keyword arguments to validate.
    :param list required_names: List of required parameter names.
    z(Required keyword argument: {} undefined.z, zUnknown keyword argument(s): {})ÚpopÚKeyErrorÚ	TypeErrorÚformatÚjoinÚkeys)r   r	   Úvalidated_kwargsÚnameÚunknown© r   úU/opt/certbot/lib/python3.10/site-packages/certbot_apache/_internal/parsernode_util.pyÚvalidate_kwargs   s   
ÿr   c                 C   sV   d| v r
|   dd¡ |   dd¡ |   di ¡ t| g d¢ƒ} | d | d | d | d fS )aF  
    Validates keyword arguments for ParserNode. This function modifies the kwargs
    dictionary, and hence the returned dictionary should be used instead in the
    caller function instead of the original kwargs.

    If metadata is provided, the otherwise required argument "filepath" may be
    omitted if the implementation is able to extract its value from the metadata.
    This usecase is handled within this function. Filepath defaults to None.

    :param dict kwargs: Keyword argument dictionary to validate.

    :returns: Tuple of validated and prepared arguments.
    ÚmetadataÚfilepathNÚdirtyF)Úancestorr   r   r   r   )Ú
setdefaultr   )r   r   r   r   Úparsernode_kwargs#   s   r   c                 C   sX   d| v r|   dd¡ |   dd¡ |   dd¡ |   di ¡ t| g d¢ƒ} |  d¡}|| fS )au  
    Validates keyword arguments for CommentNode and sets the default values for
    optional kwargs. This function modifies the kwargs dictionary, and hence the
    returned dictionary should be used instead in the caller function instead of
    the original kwargs.

    If metadata is provided, the otherwise required argument "comment" may be
    omitted if the implementation is able to extract its value from the metadata.
    This usecase is handled within this function.

    :param dict kwargs: Keyword argument dictionary to validate.

    :returns: Tuple of validated and prepared arguments and ParserNode kwargs.
    r   ÚcommentNr   r   F)r   r   r   r   r   ©r   r   r   )r   r   r   r   r   Úcommentnode_kwargsB   s   
r   .c                 C   sˆ   d| v r|   dd¡ |   dd¡ |   dd¡ |   dd¡ |   d	d
¡ |   di ¡ t| g d¢ƒ} |  d¡}|  d	¡}|  d¡}|||| fS )a‚  
    Validates keyword arguments for DirectiveNode and BlockNode and sets the
    default values for optional kwargs. This function modifies the kwargs
    dictionary, and hence the returned dictionary should be used instead in the
    caller function instead of the original kwargs.

    If metadata is provided, the otherwise required argument "name" may be
    omitted if the implementation is able to extract its value from the metadata.
    This usecase is handled within this function.

    :param dict kwargs: Keyword argument dictionary to validate.

    :returns: Tuple of validated and prepared arguments and ParserNode kwargs.
    r   r   Nr   r   FÚenabledTÚ
parametersr   )r   r   r   r   r!   r    r   r   )r   r   r!   r    r   r   r   Údirectivenode_kwargse   s   


r"   N)Ú__doc__Útypingr   r   r   r   r   Ú#certbot_apache._internal.interfacesr   Ústrr   Úboolr   r   r"   r   r   r   r   Ú<module>   s    *
ÿ.#"ÿ