o
    2cf(                     @   s$  d dl mZ d dlmZmZ d dlmZmZ d dlZdZ	dd Z
dd	 Zd
d ZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZdS )&    )unicode_literals)escapeMarkup)	text_type	iteritemsN)CheckboxInput	FileInputHiddenInput
ListWidgetPasswordInput
RadioInputSelectSubmitInputTableWidgetTextArea	TextInputOption
HTMLStringescape_htmlc                  O      t jdtdd t| i |S )NzM'HTMLString' will be removed in WTForms 3.0. Use 'markupsafe.Markup' instead.   
stacklevel)warningswarnDeprecationWarningr   argskwargs r   J/var/www/html/gps/gps/lib/python3.10/site-packages/wtforms/widgets/core.pyr         r   c                  O   r   )NzN'escape_html' will be removed in WTForms 3.0. Use 'markupsafe.escape' instead.r   r   )r   r   r   r   r   r   r   r    r      r!   r   c                  K   s   g }t t| D ];\}}|dv r|dd }n|ds!|dr'|dd}|du r1|| q|d	u r6q|d
t|t|f  qd|S )a  
    Generate HTML attribute syntax from inputted keyword arguments.

    The output value is sorted by the passed keys, to provide consistent output
    each time this function is called with the same parameters. Because of the
    frequent use of the normally reserved keywords `class` and `for`, suffixing
    these with an underscore will allow them to be used.

    In order to facilitate the use of ``data-`` and ``aria-`` attributes, if the
    name of the attribute begins with ``data_`` or ``aria_``, then every
    underscore will be replaced with a hyphen in the generated attribute.

    >>> html_params(data_attr='user.name', aria_labeledby='name')
    'data-attr="user.name" aria-labeledby="name"'

    In addition, the values ``True`` and ``False`` are special:
      * ``attr=True`` generates the HTML compact output of a boolean attribute,
        e.g. ``checked=True`` will generate simply ``checked``
      * ``attr=False`` will be ignored and generate no output.

    >>> html_params(name='text1', id='f', class_='text')
    'class="text" id="f" name="text1"'
    >>> html_params(checked=True, readonly=False, name="text1", abc="hello")
    'abc="hello" checked name="text1"'
    )class_class__for_Ndata_aria__-TFz%s="%s" )sortedr   
startswithreplaceappendr   r   join)r   paramskvr   r   r    html_params$   s   
r3   c                   @   s"   e Zd ZdZd	ddZdd ZdS )
r
   a  
    Renders a list of fields as a `ul` or `ol` list.

    This is used for fields which encapsulate many inner fields as subfields.
    The widget will try to iterate the field to get access to the subfields and
    call them to render them.

    If `prefix_label` is set, the subfield's label is printed before the field,
    otherwise afterwards. The latter is useful for iterating radios or
    checkboxes.
    ulTc                 C   s   |dv sJ || _ || _d S )N)olr4   )html_tagprefix_label)selfr6   r7   r   r   r    __init__Y   s   
zListWidget.__init__c                 K   s   | d|j d| jtdi |f g}|D ]}| jr'|d|j| f  q|d| |jf  q|d| j  td|S )Nidz<%s %s>z<li>%s %s</li>z</%s> r   )	
setdefaultr:   r6   r3   r7   r.   labelr   r/   )r8   fieldr   htmlsubfieldr   r   r    __call__^   s   zListWidget.__call__N)r4   T__name__
__module____qualname____doc__r9   rA   r   r   r   r    r
   M   s    
r
   c                   @   s"   e Zd ZdZdddZdd ZdS )	r   a  
    Renders a list of fields as a set of table rows with th/td pairs.

    If `with_table_tag` is True, then an enclosing <table> is placed around the
    rows.

    Hidden fields will not be displayed with a row, instead the field will be
    pushed into a subsequent table row to ensure XHTML validity. Hidden fields
    at the end of the field list will appear outside the table.
    Tc                 C   
   || _ d S N)with_table_tag)r8   rI   r   r   r    r9   u      
zTableWidget.__init__c                 K   s   g }| j r|d|j |dtdi |  d}|D ]}|jdv r*|t|7 }q|dt|j|t|f  d}q| j rD|d |rK|| td	|S )Nr:   z
<table %s>r;   )HiddenFieldCSRFTokenFieldz!<tr><th>%s</th><td>%s%s</td></tr>z</table>r   )
rI   r<   r:   r.   r3   typer   r=   r   r/   )r8   r>   r   r?   hiddenr@   r   r   r    rA   x   s   


zTableWidget.__call__NTrB   r   r   r   r    r   j   s    

r   c                   @   s*   e Zd ZdZeeZdddZdd ZdS )Inputz
    Render a basic ``<input>`` field.

    This is used as the basis for most of the other input fields.

    By default, the `_value()` method will be called upon the associated field
    to provide the ``value=`` HTML attribute.
    Nc                 C   s   |d ur	|| _ d S d S rH   )
input_type)r8   rQ   r   r   r    r9      s   
zInput.__init__c                 K   sn   | d|j | d| j d|vr| |d< d|vr(dt|dg v r(d|d< td| jd	d|ji| S )
Nr:   rM   valuerequiredflagsTz
<input %s>namer   )r<   r:   rQ   _valuegetattrr   r3   rU   r8   r>   r   r   r   r    rA      s   zInput.__call__rH   )rC   rD   rE   rF   staticmethodr3   r9   rA   r   r   r   r    rP      s
    
rP   c                   @   s   e Zd ZdZdZdS )r   z*
    Render a single-line text input.
    textN)rC   rD   rE   rF   rQ   r   r   r   r    r      s    r   c                       s.   e Zd ZdZdZdddZ fddZ  ZS )	r   z
    Render a password input.

    For security purposes, this field will not reproduce the value on a form
    submit by default. To have the value filled in, set `hide_value` to
    `False`.
    passwordTc                 C   rG   rH   )
hide_value)r8   r\   r   r   r    r9      rJ   zPasswordInput.__init__c                    s&   | j rd|d< tt| j|fi |S )Nr;   rR   )r\   superr   rA   rX   	__class__r   r    rA         zPasswordInput.__call__rO   rC   rD   rE   rF   rQ   r9   rA   __classcell__r   r   r^   r    r      s
    
r   c                   @   s   e Zd ZdZdZdZdS )r	   z 
    Render a hidden input.
    )rN   rN   N)rC   rD   rE   rF   field_flagsrQ   r   r   r   r    r	      s    r	   c                       $   e Zd ZdZdZ fddZ  ZS )r   zq
    Render a checkbox.

    The ``checked`` HTML attribute is set if the field's data is a non-false value.
    checkboxc                    s.   t |d|jrd|d< tt| j|fi |S )NcheckedT)rW   datar]   r   rA   rX   r^   r   r    rA      s   zCheckboxInput.__call__rC   rD   rE   rF   rQ   rA   rb   r   r   r^   r    r      s    r   c                       rd   )r   z
    Render a single radio button.

    This widget is most commonly used in conjunction with ListWidget or some
    other listing, as singular radio buttons are not very useful.
    radioc                    s&   |j rd|d< tt| j|fi |S )NTrf   )rf   r]   r   rA   rX   r^   r   r    rA      r`   zRadioInput.__call__rh   r   r   r^   r    r          r   c                       s2   e Zd ZdZdZd fdd	Z fddZ  ZS )	r   zURender a file chooser input.

    :param multiple: allow choosing multiple files
    fileFc                    s   t t|   || _d S rH   )r]   r   r9   multipler8   rl   r^   r   r    r9      s   
zFileInput.__init__c                    s.   d|d< | j rd|d< tt| j|fi |S )NFrR   Trl   )rl   r]   r   rA   rX   r^   r   r    rA      s   zFileInput.__call__Fra   r   r   r^   r    r      s
    r   c                       rd   )r   z
    Renders a submit button.

    The field's label is used as the text of the submit button instead of the
    data on the field.
    submitc                    s(   | d|jj tt| j|fi |S )NrR   )r<   r=   rZ   r]   r   rA   rX   r^   r   r    rA     s   zSubmitInput.__call__rh   r   r   r^   r    r      rj   r   c                   @      e Zd ZdZdd ZdS )r   zs
    Renders a multi-line text area.

    `rows` and `cols` ought to be passed as keyword args when rendering.
    c                 K   sV   | d|j d|vrdt|dg v rd|d< tdtdd|ji|t| f S )Nr:   rS   rT   Tz<textarea %s>
%s</textarea>rU   r   )r<   r:   rW   r   r3   rU   r   rV   rX   r   r   r    rA     s   
zTextArea.__call__NrC   rD   rE   rF   rA   r   r   r   r    r     s    r   c                   @   s.   e Zd ZdZd
ddZdd Zedd Zd	S )r   a:  
    Renders a select field.

    If `multiple` is True, then the `size` property should be specified on
    rendering to make the field useful.

    The field must provide an `iter_choices()` method which the widget will
    call on rendering; this method must yield tuples of
    `(value, label, selected)`.
    Fc                 C   rG   rH   )rl   rm   r   r   r    r9   "  rJ   zSelect.__init__c                 K   s   | d|j | jrd|d< d|vrdt|dg v rd|d< dtd
d|ji| g}| D ]\}}}|| ||| q/|d t	d	
|S )Nr:   Trl   rS   rT   z<select %s>rU   z	</select>r;   r   )r<   r:   rl   rW   r3   rU   iter_choicesr.   render_optionr   r/   )r8   r>   r   r?   valr=   selectedr   r   r    rA   %  s   
zSelect.__call__c                 K   sF   |du rt |}t||d}|rd|d< tdtdi |t|f S )NT)rR   ru   z<option %s>%s</option>r   )r   dictr   r3   r   )clsrR   r=   ru   r   optionsr   r   r    rs   1  s   zSelect.render_optionNrn   )rC   rD   rE   rF   r9   rA   classmethodrs   r   r   r   r    r     s    

r   c                   @   rp   )r   z
    Renders the individual option from a select field.

    This is just a convenience for various custom rendering situations, and an
    option by itself does not constitute an entire field.
    c                 K   s    t j| |jj|jfi |S rH   )r   rs   rV   r=   rZ   rf   rX   r   r   r    rA   D  s    zOption.__call__Nrq   r   r   r   r    r   =  s    r   )
__future__r   
markupsafer   r   wtforms.compatr   r   r   __all__r   r   r3   objectr
   r   rP   r   r   r	   r   r   r   r   r   r   r   r   r   r   r    <module>   s*    

)!&