File: //usr/lib/python3/dist-packages/django/forms/__pycache__/utils.cpython-310.pyc
o
3�al � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl m
Z
mZmZm
Z
d dlmZ dd � Zd
d� Ze
G dd
� d
e��Ze
G dd� dee��Zdd� Zdd� ZdS )� N)�UserList)�settings)�ValidationError)�timezone)�escape�format_html�format_html_join� html_safe)�gettext_lazyc C s | sdS | � dd��� S )z%Convert 'first_name' to 'First name'.� �_� )�replace�
capitalize)�name� r �4/usr/lib/python3/dist-packages/django/forms/utils.py�pretty_name s r c C sl g }g }| � � D ]\}}t|t�r|r|�|f� q|dur%|�||f� qtddt|��tddt|�� S )a�
Convert a dictionary of attributes to a single string.
The returned string will contain a leading space followed by key="value",
XML-style pairs. In the case of a boolean value, the key will appear
without a value. It is assumed that the keys do not need to be
XML-escaped. If the passed dictionary is empty, then return an empty
string.
The result is passed through 'mark_safe' (by way of 'format_html_join').
Nr z {}="{}"z {})�items�
isinstance�bool�appendr �sorted)�attrs�key_value_attrs�
boolean_attrs�attr�valuer r r �flatatt s
����r c @ sD e Zd ZdZdd� Zddd�Zddd�Zd d
� Zdd� Zd
d� Z dS )� ErrorDictz�
A collection of errors that knows how to display itself in various formats.
The dictionary keys are the field names, and the values are the errors.
c C s dd� | � � D �S )Nc S s i | ] \}}||� � �qS r )�as_data��.0�f�er r r �
<dictcomp>4 s z%ErrorDict.as_data.<locals>.<dictcomp>�r ��selfr r r r 3 s zErrorDict.as_dataFc s � fdd�| � � D �S )Nc s i | ]
\}}||� � ��qS r )�
get_json_datar! ��escape_htmlr r r% 7 s z+ErrorDict.get_json_data.<locals>.<dictcomp>r&