ó
pÁìVc           @  s˜   d  Z  d d l m Z d d l m Z d d l m Z m Z d d l m	 Z	 d d l
 m Z m Z m Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   uœ   
Content negotiation deals with selecting an appropriate renderer given the
incoming request.  Typically this will be based on the request's Accept header.
iÿÿÿÿ(   t   unicode_literals(   t   Http404(   t   HTTP_HEADER_ENCODINGt
   exceptions(   t   api_settings(   t
   _MediaTypet   media_type_matchest   order_by_precedencet   BaseContentNegotiationc           B  s   e  Z d  „  Z d d „ Z RS(   c         C  s   t  d ƒ ‚ d  S(   Nu$   .select_parser() must be implemented(   t   NotImplementedError(   t   selft   requestt   parsers(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyt   select_parser   s    c         C  s   t  d ƒ ‚ d  S(   Nu&   .select_renderer() must be implemented(   R	   (   R
   R   t	   rendererst   format_suffix(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyt   select_renderer   s    N(   t   __name__t
   __module__R   t   NoneR   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyR      s   	t   DefaultContentNegotiationc           B  s5   e  Z e Z d  „  Z d d „ Z d „  Z d „  Z RS(   c         C  s.   x' | D] } t  | j | j ƒ r | Sq Wd S(   u   
        Given a list of parsers and a media type, return the appropriate
        parser to handle the incoming request.
        N(   R   t
   media_typet   content_typeR   (   R
   R   R   t   parser(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyR      s    c      	   C  s  |  j  j } | p! | j j | ƒ } | r? |  j | | ƒ } n  |  j | ƒ } x¸ t | ƒ D]ª } x¡ | D]™ } x | D]ˆ }	 t | j |	 ƒ ru t	 |	 ƒ }
 t	 | j ƒ j
 |
 j
 k rð d j | j f t d „  |
 j j ƒ  Dƒ ƒ ƒ } | | f S| |	 f Squ qu Wqh Wq[ Wt j d | ƒ ‚ d S(   uq   
        Given a request and a list of renderers, return a two-tuple of:
        (renderer, media type).
        u   ;c         s  s0   |  ]& \ } } d  j  | | j t ƒ ƒ Vq d S(   u   {0}={1}N(   t   formatt   decodeR   (   t   .0t   keyt   value(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pys	   <genexpr>E   s   t   available_renderersN(   t   settingst   URL_FORMAT_OVERRIDEt   query_paramst   gett   filter_rendererst   get_accept_listR   R   R   R   t
   precedencet   joint   tuplet   paramst   itemsR   t   NotAcceptable(   R
   R   R   R   t   format_query_paramR   t   acceptst   media_type_sett   rendererR   t   media_type_wrappert   full_media_type(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyR   %   s&    		
c         C  s;   g  | D] } | j  | k r | ^ q } | s7 t ‚ n  | S(   uœ   
        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   R-   (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyR"   P   s
    	c         C  s;   | j  j d d ƒ } g  | j d ƒ D] } | j ƒ  ^ q% S(   ud   
        Given the incoming request, return a tokenised list of media
        type strings.
        u   HTTP_ACCEPTu   */*u   ,(   t   METAR!   t   splitt   strip(   R
   R   t   headert   token(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyR#   [   s    N(	   R   R   R   R   R   R   R   R"   R#   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyR      s
   	
+	N(   t   __doc__t
   __future__R    t   django.httpR   t   rest_frameworkR   R   t   rest_framework.settingsR   t   rest_framework.utils.mediatypesR   R   R   t   objectR   R   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/negotiation.pyt   <module>   s   