
    WeIi                     D    d dl mZ d dlmZ d dlmZ  G d d          ZdS )    )i18n)WebobInputWrapper	clean_keyc                   V    e Zd ZdZd Zd Zd ZdZdZdZ	dZ
dZd ZdZd	Zi Zd
 Zd ZdS )DefaultMetaz
    This is the default Meta class which defines all the default values and
    therefore also the 'API' of the class Meta interface.
    c                       |j         dd|i|S )a  
        bind_field allows potential customization of how fields are bound.

        The default implementation simply passes the options to
        :meth:`UnboundField.bind`.

        :param form: The form.
        :param unbound_field: The unbound field.
        :param options:
            A dictionary of options which are typically passed to the field.

        :return: A bound field
        form )bind)selfr
   unbound_fieldoptionss       Q/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/wtforms/meta.py
bind_fieldzDefaultMeta.bind_field   s"     "}!77t7w777    c                     |>t          |d          s.t          |d          rt          |          S t          d          |S )aZ  
        wrap_formdata allows doing custom wrappers of WTForms formdata.

        The default implementation detects webob-style multidicts and wraps
        them, otherwise passes formdata back un-changed.

        :param form: The form.
        :param formdata: Form data.
        :return: A form-input wrapper compatible with WTForms.
        NgetlistgetallzNformdata should be a multidict-type wrapper that supports the 'getlist' method)hasattrr   	TypeError)r   r
   formdatas      r   wrap_formdatazDefaultMeta.wrap_formdata   sW     )(D(Dx** (2225   r   c                     d |                                 D             }t          |dd          }|+d |                                 D             }t          |fi |} |j        |fi |S )z
        render_field allows customization of how widget rendering is done.

        The default implementation calls ``field.widget(field, **render_kw)``
        c                 4    i | ]\  }}t          |          |S r   r   .0kvs      r   
<dictcomp>z,DefaultMeta.render_field.<locals>.<dictcomp>:   s$    CCCAYq\\1CCCr   	render_kwNc                 4    i | ]\  }}t          |          |S r   r   r   s      r   r    z,DefaultMeta.render_field.<locals>.<dictcomp>>   s$    EEEDAq	!aEEEr   )itemsgetattrdictwidget)r   fieldr!   other_kws       r   render_fieldzDefaultMeta.render_field3   s     DC1B1BCCC	5+t44EEHNN4D4DEEEHX3333Iu|E//Y///r   F
csrf_tokenNc                 X    | j         |                                  S ddlm}  |            S )a  
        Build a CSRF implementation. This is called once per form instance.

        The default implementation builds the class referenced to by
        :attr:`csrf_class` with zero arguments. If `csrf_class` is ``None``,
        will instead use the default implementation
        :class:`wtforms.csrf.session.SessionCSRF`.

        :param form: The form.
        :return: A CSRF implementation.
        Nr   )SessionCSRF)
csrf_classwtforms.csrf.sessionr,   )r   r
   r,   s      r   
build_csrfzDefaultMeta.build_csrfJ   s:     ?&??$$$444444{}}r   Tc                     | j         }|du rdS | j        rO|rt          |          nd}| j                            |          }|t          j        |          x}| j        |<   |S t          j        |          S )z
        Override in subclasses to provide alternate translations factory.
        See the i18n documentation for more.

        :param form: The form.
        :return: An object that provides gettext() and ngettext() methods.
        FN)localescache_translationstupletranslations_cachegetr   get_translations)r   r
   r1   translationss       r   r6   zDefaultMeta.get_translationsc   s     ,e4" 
	 (/9eGnnnTG266w??L#BFBWC C t6w?  $W---r   c                 \    |                                 D ]\  }}t          | ||           dS )zV
        Given a dictionary of values, update values on this `Meta` instance.
        N)r#   setattr)r   valueskeyvalues       r   update_valueszDefaultMeta.update_values   s>     !,,.. 	& 	&JCD#u%%%%	& 	&r   )__name__
__module____qualname____doc__r   r   r)   csrfcsrf_field_namecsrf_secretcsrf_contextr-   r/   r1   r2   r4   r6   r=   r   r   r   r   r      s         8 8 8   *0 0 0" D"OKLJ  * G. . .8& & & & &r   r   N)wtformsr   wtforms.utilsr   wtforms.widgets.corer   r   r   r   r   <module>rI      sw          + + + + + + * * * * * *~& ~& ~& ~& ~& ~& ~& ~& ~& ~&r   