
    h                     j    S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	J
r
   " S S5      r " S S	\5      rg
)z
Content negotiation deals with selecting an appropriate renderer given the
incoming request.  Typically this will be based on the request's Accept header.
    )Http404)
exceptions)api_settings)
_MediaTypemedia_type_matchesorder_by_precedencec                   $    \ rS rSrS rSS jrSrg)BaseContentNegotiation   c                     [        S5      e)Nz$.select_parser() must be implementedNotImplementedError)selfrequestparserss      L/var/www/html/env/lib/python3.13/site-packages/rest_framework/negotiation.pyselect_parser$BaseContentNegotiation.select_parser   s    !"HII    Nc                     [        S5      e)Nz&.select_renderer() must be implementedr   )r   r   	renderersformat_suffixs       r   select_renderer&BaseContentNegotiation.select_renderer   s    !"JKKr    N)__name__
__module____qualname____firstlineno__r   r   __static_attributes__r   r   r   r
   r
      s    JLr   r
   c                   4    \ rS rSr\rS rSS jrS rS r	Sr
g)	DefaultContentNegotiation   c                 h    U H,  n[        UR                  UR                  5      (       d  M*  Us  $    g)zi
Given a list of parsers and a media type, return the appropriate
parser to handle the incoming request.
N)r   
media_typecontent_type)r   r   r   parsers       r   r   'DefaultContentNegotiation.select_parser   s1    
 F!&"3"3W5I5IJJ  r   Nc                    U R                   R                  nU=(       d    UR                  R                  U5      nU(       a  U R	                  X%5      nU R                  U5      n[        U5       H  nU H  nU H  n	[        UR                  U	5      (       d  M   [        U	5      n
[        UR                  5      R                  U
R                  :  aP  SR                  UR                  4[        S U
R                  R                  5        5       5      -   5      nX4s  s  s  $ X4s  s  s  $    M     M     [        R                   " US9e)zY
Given a request and a list of renderers, return a two-tuple of:
(renderer, media type).
;c              3   H   #    U  H  u  pS R                  X5      v   M     g7f)z{}={}N)format).0keyvalues      r   	<genexpr><DefaultContentNegotiation.select_renderer.<locals>.<genexpr>C   s%      &"6W
 %,NN3$>$>6Ws    ")available_renderers)settingsURL_FORMAT_OVERRIDEquery_paramsgetfilter_renderersget_accept_listr   r   r&   r   
precedencejointupleparamsitemsr   NotAcceptable)r   r   r   r   format_query_paramr-   acceptsmedia_type_setrendererr&   media_type_wrapperfull_media_types               r   r   )DefaultContentNegotiation.select_renderer#   s&    "]]>>N'"6"6":":;M"N--i@I&&w/ 2':N%"0J)(*=*=zJJ-7
-C*&x':':;FF.99:
 /2hh!)!4!4 6 % &"6H6O6O6U6U6W&" !"!"/O $,#<< $,#77+ #1 & ;2 &&9EEr   c                 r    U Vs/ s H  nUR                   U:X  d  M  UPM     nnU(       d  [        eU$ s  snf )z
If there is a '.json' style format suffix, filter the renderers
so that we only negotiation against those that accept that format.
)r-   r   )r   r   r-   rC   s       r   r8   *DefaultContentNegotiation.filter_renderersP   s>    
 /8 3i( 61 i	 3M	3s   44c                     UR                   R                  SS5      nUR                  S5       Vs/ s H  o3R                  5       PM     sn$ s  snf )zL
Given the incoming request, return a tokenized list of media
type strings.
HTTP_ACCEPTz*/*,)METAr7   splitstrip)r   r   headertokens       r   r9   )DefaultContentNegotiation.get_accept_list[   sA    
 !!-7+1<<+<=+<%+<===s   Ar   r   )r   r   r   r    r   r4   r   r   r8   r9   r!   r   r   r   r#   r#      s    H+FZ	>r   r#   N)__doc__django.httpr   rest_frameworkr   rest_framework.settingsr   rest_framework.utils.mediatypesr   r   r   r
   r#   r   r   r   <module>rW      s:      % 0 
L LK> 6 K>r   