
    h                     6    S r SSKrSSKJr  S rSS jrSS jrg)	z&
Helpers for dealing with HTML input.
    N)MultiValueDictc                     [        U S5      $ )Ngetlist)hasattr)
dictionarys    K/var/www/html/env/lib/python3.13/site-packages/rest_framework/utils/html.pyis_html_inputr	   	   s     :y))    c                    0 n[         R                  " S[         R                  " U5      -  5      nU R                  5        H  u  pVUR	                  U5      nU(       d  M  UR                  5       u  p[        U5      nU	(       d  XcU'   MI  [        UR                  U5      [        5      (       a	  XcU   U	'   Mv  [        X/05      X8'   M     U(       a  [        U5       V
s/ s H  oU
   PM	     sn
$ U$ s  sn
f )a  
Used to support list values in HTML forms.
Supports lists of primitives and/or dictionaries.

* List of primitives.

{
    '[0]': 'abc',
    '[1]': 'def',
    '[2]': 'hij'
}
    -->
[
    'abc',
    'def',
    'hij'
]

* List of dictionaries.

{
    '[0]foo': 'abc',
    '[0]bar': 'def',
    '[1]foo': 'hij',
    '[1]bar': 'klm',
}
    -->
[
    {'foo': 'abc', 'bar': 'def'},
    {'foo': 'hij', 'bar': 'klm'}
]

:returns a list of objects, or the value specified in ``default`` if the list is empty
z^%s\[([0-9]+)\](.*)$)recompileescapeitemsmatchgroupsint
isinstancegetdictr   sorted)r   prefixdefaultretregexfieldvaluer   indexkeyitems              r   parse_html_listr       s    F CJJ.61BBCE"((*E"\\^
E
J--#JsO'g7CJ + 36&+.+$I+.B7B.s   C0c                 $   [        5       n[        R                  " S[        R                  " U5      -  5      nU  HR  nUR	                  U5      nU(       d  M  UR                  5       S   nU R                  U5      nUR                  Xg5        MT     U$ )z
Used to support dictionary values in HTML forms.

{
    'profile.username': 'example',
    'profile.email': 'example@example.com',
}
    -->
{
    'profile': {
        'username': 'example',
        'email': 'example@example.com'
    }
}
z
^%s\.(.+)$r   )r   r   r   r   r   r   r   setlist)r   r   r   r   r   r   r   r   s           r   parse_html_dictr#   E   sy      
CJJ}ryy'889EE"llnQ""5)C  Jr
   ) N)r$   )__doc__r   django.utils.datastructuresr   r	   r    r#    r
   r   <module>r(      s#    
 6*3Clr
   