
    ht                         d dl 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
mZmZmZ d dlmZ d Zd	 Ze G d
 de             Ze G d dee             Zd Zd Zy)    N)UserList)settings)ValidationError)timezone)escapeformat_htmlformat_html_join	html_safe)gettext_lazyc                 H    | sy| j                  dd      j                         S )z%Convert 'first_name' to 'First name'. _ )replace
capitalize)names    U/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/forms/utils.pypretty_namer      s"    <<S!,,..    c                    g }g }| j                         D ]A  \  }}t        |t              r|s|j                  |f       ,|/|j                  ||f       C t	        ddt        |            t	        ddt        |            z   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').
    r   z {}="{}"z {})items
isinstanceboolappendr	   sorted)attrskey_value_attrsboolean_attrsattrvalues        r   flatattr!      s     OM{{} 2eeT"$$dW-""D%=12 	Z)@AUF=$9:	;r   c                   8    e Zd ZdZd Zd	dZd	dZd Zd Zd Z	y)
	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                 r    | j                         D ci c]  \  }}||j                          c}}S c c}}w N)r   as_data)selffes      r   r&   zErrorDict.as_data3   s*    +/::<841a199;888s   3c                 t    | j                         D ci c]  \  }}||j                  |       c}}S c c}}w r%   )r   get_json_data)r'   escape_htmlr(   r)   s       r   r+   zErrorDict.get_json_data6   s.    <@JJLIDAq1??;//IIIs   4c                 J    t        j                  | j                  |            S r%   jsondumpsr+   r'   r,   s     r   as_jsonzErrorDict.as_json9       zz$,,[9::r   c           	      R    | syt        dt        dd| j                                     S )Nr   z<ul class="errorlist">{}</ul>z<li>{}{}</li>)r   r	   r   r'   s    r   as_ulzErrorDict.as_ul<   s*    +R$**,?
 	
r   c                     g }| j                         D ]@  \  }}|j                  d|z         |j                  dj                  d |D                     B dj                  |      S )N* %s
c              3   &   K   | ]	  }d |z    yw)z  * %sN .0r)   s     r   	<genexpr>z$ErrorDict.as_text.<locals>.<genexpr>H   s     #AQHqL#A   )r   r   join)r'   outputfielderrorss       r   as_textzErrorDict.as_textD   s^    !ZZ\ 	CME6MM&5.)MM$))#A&#AAB	C yy  r   c                 "    | j                         S r%   r6   r5   s    r   __str__zErrorDict.__str__K       zz|r   NF)
__name__
__module____qualname____doc__r&   r+   r2   r6   rD   rG   r;   r   r   r#   r#   ,   s&    
9J;
!r   r#   c                   x     e Zd ZdZd fd	Zd Z fdZddZddZd Z	d Z
d	 Zd
 Zd Zd Zd Z fdZ xZS )	ErrorListzU
    A collection of errors that knows how to display itself in various formats.
    c                 d    t         |   |       |d| _        y dj                  |      | _        y )N	errorlistzerrorlist {})super__init__error_classformat)r'   initlistrT   	__class__s      r   rS   zErrorList.__init__T   s1    "*D-44[ADr   c                 @    t        | j                        j                  S r%   )r   data
error_listr5   s    r   r&   zErrorList.as_data\   s    tyy)444r   c                 F    t         |          }| j                  |_        |S r%   )rR   copyrT   )r'   r\   rW   s     r   r\   zErrorList.copy_   s!    w|~++r   c                     g }| j                         D ]E  }t        t        |            }|j                  |rt	        |      n||j
                  xs dd       G |S )Nr   )messagecode)r&   nextiterr   r   r_   )r'   r,   rC   errorr^   s        r   r+   zErrorList.get_json_datad   sY    \\^ 	E4;'GMM.96'?w

(b 	 r   c                 J    t        j                  | j                  |            S r%   r.   r1   s     r   r2   zErrorList.as_jsonn   r3   r   c           
      n    | j                   syt        d| j                  t        ddd | D                    S )Nr   z<ul class="{}">{}</ul>z<li>{}</li>c              3   "   K   | ]  }|f 	 y wr%   r;   r<   s     r   r>   z"ErrorList.as_ul.<locals>.<genexpr>x   s     0D!!0Ds   )rY   r   rT   r	   r5   s    r   r6   zErrorList.as_ulq   s7    yy$R0Dt0DE
 	
r   c                 2    dj                  d | D              S )Nr9   c              3   &   K   | ]	  }d |z    yw)r8   Nr;   r<   s     r   r>   z$ErrorList.as_text.<locals>.<genexpr>|   s     2!2r?   )r@   r5   s    r   rD   zErrorList.as_text{   s    yy2T222r   c                 "    | j                         S r%   rF   r5   s    r   rG   zErrorList.__str__~   rH   r   c                 *    t        t        |             S r%   )reprlistr5   s    r   __repr__zErrorList.__repr__   s    DJr   c                     |t        |       v S r%   rk   )r'   items     r   __contains__zErrorList.__contains__   s    tDz!!r   c                     t        |       |k(  S r%   rn   )r'   others     r   __eq__zErrorList.__eq__   s    DzU""r   c                 l    | j                   |   }t        |t              rt        t	        |            S |S r%   )rY   r   r   r`   ra   )r'   irb   s      r   __getitem__zErrorList.__getitem__   s-    		!e_-U$$r   c                 :    t        t        | 
  |i |}|d d dz   S )N   NN)rR   r   __reduce_ex__)r'   argskwargsinforW   s       r   rz   zErrorList.__reduce_ex__   s,     Xt2DCFCBQx,&&r   ry   rI   )rJ   rK   rL   rM   rS   r&   r\   r+   r2   r6   rD   rG   rl   rp   rs   rv   rz   __classcell__)rW   s   @r   rO   rO   O   sO    B5
;
3 "#' 'r   rO   c                    t         j                  rB| @t        j                  |       r+t        j                         }	 t        j
                  | |      S | S # t        $ r }t        t        d      d| |d      |d}~ww xY w)z}
    When time zone support is enabled, convert naive datetimes
    entered in the current time zone to aware datetimes.
    Nur   %(datetime)s couldn’t be interpreted in time zone %(current_timezone)s; it may be ambiguous or it may not exist.ambiguous_timezone)datetimecurrent_timezone)r_   params)	r   USE_TZr   is_naiveget_current_timezone
make_aware	Exceptionr   r   )r    r   excs      r   from_current_timezoner      s    
 5,1B1B51I#88:		&&u.>?? L  	! : ; *$)?OP 	s   A 	A>A99A>c                 ~    t         j                  r,| *t        j                  |       rt        j                  |       S | S )z
    When time zone support is enabled, convert aware datetimes
    to naive datetimes in the current time zone for display.
    )r   r   r   is_aware
make_naive)r    s    r   to_current_timezoner      s3    
 5,1B1B51I""5))Lr   )r/   collectionsr   django.confr   django.core.exceptionsr   django.utilsr   django.utils.htmlr   r   r	   r
   django.utils.translationr   r   r   r!   dictr#   rk   rO   r   r   r;   r   r   <module>r      sn         2 ! N N 6/4   D G'$ G' G'X(r   