o
    &Zc1  ã                   @   s8   d Z ddlmZ ddlZe d¡Zd
dd„Zdd	„ ZdS )aÜ  
This module contains code from django.template.base
(sha 90d3af380e8efec0301dd91600c6686232de3943). Bundling this code allows us to
support older versions of Django that did not contain it (< 1.4).


Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, 
       this list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright 
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.

    3. Neither the name of Django nor the names of its contributors may be used
       to endorse or promote products derived from this software without
       specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

é    )ÚTemplateSyntaxErrorNz(?:(\w+)=)?(.+)Fc                 C   s   | si S t  | d ¡}|o| d¡}|s&|si S t| ƒdk s$| d dkr&i S i }| r~|rHt  | d ¡}|r:| d¡s<|S | ¡ \}}| dd…= nt| ƒdk sT| d dkrV|S | d | d }}| dd…= | |¡||< | r||s|| d dkrw|S | dd…= | s*|S )a²  
    A utility method for parsing token keyword arguments.

    :param bits: A list containing remainder of the token (split by spaces)
        that is to be checked for arguments. Valid arguments will be removed
        from this list.

    :param support_legacy: If set to true ``True``, the legacy format
        ``1 as foo`` will be accepted. Otherwise, only the standard ``foo=1``
        format is allowed.

    :returns: A dictionary of the arguments retrieved from the ``bits`` token
        list.

    There is no requirement for all remaining token ``bits`` to be keyword
    arguments, so the dictionary will be returned as soon as an invalid
    argument format is reached.
    r   é   é   ÚasNé   Úand)Úkwarg_reÚmatchÚgroupÚlenÚgroupsÚcompile_filter)ÚbitsÚparserÚsupport_legacyr	   Úkwarg_formatÚkwargsÚkeyÚvalue© r   úD/var/www/jaguar/venv/lib/python3.10/site-packages/imagekit/compat.pyÚtoken_kwargs.   s8   

ðr   c              	   C   sZ  |r|d dkr|dd… }nt d| ƒ‚g }i }	t|ƒ}
|D ]j}t|g| ƒ}|r_t| ¡ ƒd \}}||vrC|du rCt d||f ƒ‚||	v rOt d||f ƒ‚||	t|ƒ< ||
v r^|
 |¡ q|	rgt d| ƒ‚| |  |¡¡ z|
 d¡ W q t	y‰   |du r‡t d	| ƒ‚Y qw |dur—|
dt
|ƒ … }
|
r©t d
|d dd„ |
D ƒ¡f ƒ‚||	fS )zÁ
    Parses bits for template tag helpers (simple_tag, include_tag and
    assignment_tag), in particular by detecting syntax errors and by
    extracting positional and keyword arguments.
    r   Úcontextr   NzW'%s' is decorated with takes_context=True so it must have a first argument of 'context'z.'%s' received unexpected keyword argument '%s'z7'%s' received multiple values for keyword argument '%s'zH'%s' received some positional argument(s) after some keyword argument(s)z+'%s' received too many positional argumentsz5'%s' did not receive value(s) for the argument(s): %sz, c                 S   s   g | ]}d | ‘qS )z'%s'r   )Ú.0Úpr   r   r   Ú
<listcomp>    s    zparse_bits.<locals>.<listcomp>)r   Úlistr   ÚitemsÚstrÚremoveÚappendr   ÚpopÚ
IndexErrorr   Újoin)r   r   ÚparamsÚvarargsÚvarkwÚdefaultsÚtakes_contextÚnameÚargsr   Úunhandled_paramsÚbitÚkwargÚparamr   r   r   r   Ú
parse_bits`   st   ÿÿÿÿÿÿ
€ÿÿÿÿÿÿÿÿr/   )F)Ú__doc__Údjango.templater   ÚreÚcompiler   r   r/   r   r   r   r   Ú<module>   s   $

2