
    Nwg                     N    d dl mZmZmZmZmZ d dlmZ d dlm	Z	 d Z
ddZd	dZy)
    )URLResolverincludepathre_pathregister_converter)RoutePattern)api_settingsc                     |r.t        |      dk(  r|d   }nddj                  |      z  }d|z  nd G fdd      }d	}|r|d
d
j                  |      z   z  }||fS )N   r   z(?:%s)|z\.%s/?z\.[a-z0-9]+/?c                        e Zd ZW  Zd Zd Zy)9_get_format_path_converter.<locals>.FormatSuffixConverterc                 $    |j                  d      S )Nz./)stripselfvalues     Q/var/www/horilla/myenv/lib/python3.12/site-packages/rest_framework/urlpatterns.py	to_pythonzC_get_format_path_converter.<locals>.FormatSuffixConverter.to_python   s    ;;t$$    c                     d|z   dz   S )N./ r   s     r   to_urlz@_get_format_path_converter.<locals>.FormatSuffixConverter.to_url   s    ;$$r   N)__name__
__module____qualname__regexr   r   )suffix_patterns   r   FormatSuffixConverterr      s    	%	%r   r!   drf_format_suffix_)lenjoin)suffix_kwargallowedallowed_patternr!   converter_namer    s        @r   _get_format_path_converterr*      su    w<1%ajO&')::O"_4)% % )N# 111000r   Nc                    g }| D ]  }t        |t              r|j                  j                  j                  }|j                  }|j
                  }|j                  }	t        |j                  |||      }
t        |j                  t              r7t        J t        |j                        }t        |t        |
|f|      |	      }nt        |t        |
|f|      |	      }|j                  |       |j                  j                  j                  j                  d      j                  d      |z   }|j                   }|j"                  }	|j$                  }|s|j                  |       t        |j                  t              rQt        J |J t        |j                        j                  d      j                  d      |z   }t        |||	|      }nt        |||	|      }|j                  |        |S )N$r   )
isinstancer   patternr   	namespaceapp_namedefault_kwargsapply_suffix_patternsurl_patternsr   r   strr   r   appendrstripcallbackdefault_argsname)urlpatternsr    suffix_requiredsuffix_routeret
urlpatternr   r/   r0   kwargspatternsroutenew_patternviewr9   s                  r   r2   r2   !   s   
C! )$
j+.&&,,44E",,I!**H..F,Z-D-D-;-<-9;H *,,l;'''J../"5'8X2F	*RTZ[%eWh5I9-UW]^JJ{# &&,,44;;C@GGL~]E&&D,,F??D"

:& *,,l;'''#///J../66s;BB3G,V"5$=%eT64@JJ{#S)$V Jr   c                     t         j                  }|r2t        |      dk(  r|d   }nddj                  |      z  }d|d|d}nd|z  }t	        ||      \  }}t        ||       d	|d
|d}t        | |||      S )a  
    Supplement existing urlpatterns with corresponding patterns that also
    include a '.format' suffix.  Retains urlpattern ordering.

    urlpatterns:
        A list of URL patterns.

    suffix_required:
        If `True`, only suffixed URLs will be generated, and non-suffixed
        URLs will not be used.  Defaults to `False`.

    allowed:
        An optional tuple/list of allowed suffixes.  eg ['json', 'api']
        Defaults to `None`, which allows any suffix.
    r   r   z(%s)r   z\.(?P<>z)/?$z\.(?P<%s>[a-z0-9]+)/?$<:)r	   FORMAT_SUFFIX_KWARGr$   r%   r*   r   r2   )	r:   r;   r'   r&   r(   r    r)   suffix_converterr<   s	            r   format_suffix_patternsrJ   Q   s       33Lw<1%ajO$sxx'88O/;_M2\A'A,PW'X$N$'8 .=L no|\\r   )N)FN)django.urlsr   r   r   r   r   django.urls.resolversr   rest_framework.settingsr	   r*   r2   rJ   r   r   r   <module>rN      s"    O O . 014-`]r   