ó
pÁìVc           @  s‡  d  Z  d d l m Z d d l Z d d l m Z d d l m Z d d l m	 Z
 d d l m Z d d l m Z d d	 l m Z m Z d
 „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d  „  ƒ  YZ d S(!   u·   
Handled exceptions raised by REST framework.

In addition Django's built in 403 and 404 exceptions are handled.
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
iÿÿÿÿ(   t   unicode_literalsN(   t   six(   t
   force_text(   t   ugettext_lazy(   t	   ungettext(   t   status(   t
   ReturnDictt
   ReturnListc         C  s©   t  |  t ƒ rT g  |  D] } t | ƒ ^ q } t  |  t ƒ rP t | d |  j ƒS|  St  |  t ƒ rŸ d „  |  j ƒ  Dƒ } t  |  t ƒ r› t | d |  j ƒS|  St |  ƒ S(   ui   
    Descend into a nested data structure, forcing any
    lazy translation strings into plain text.
    t
   serializerc         S  s%   i  |  ] \ } } t  | ƒ | “ q S(    (   t   _force_text_recursive(   t   .0t   keyt   value(    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pys
   <dictcomp>"   s   	(	   t
   isinstancet   listR	   R   R   t   dictt   itemsR   R   (   t   datat   itemt   ret(    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR	      s    t   APIExceptionc           B  s8   e  Z d  Z e j Z e d ƒ Z d d „ Z	 d „  Z
 RS(   u‚   
    Base class for REST framework exceptions.
    Subclasses should provide `.status_code` and `.default_detail` properties.
    u   A server error occurred.c         C  s4   | d  k	 r t | ƒ |  _ n t |  j ƒ |  _ d  S(   N(   t   NoneR   t   detailt   default_detail(   t   selfR   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyt   __init__3   s    c         C  s   |  j  S(   N(   R   (   R   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyt   __str__9   s    N(   t   __name__t
   __module__t   __doc__R   t   HTTP_500_INTERNAL_SERVER_ERRORt   status_codet   _R   R   R   R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   +   s
   	t   ValidationErrorc           B  s#   e  Z e j Z d  „  Z d „  Z RS(   c         C  s?   t  | t ƒ r, t  | t ƒ r, | g } n  t | ƒ |  _ d  S(   N(   R   R   R   R	   R   (   R   R   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   G   s     c         C  s   t  j |  j ƒ S(   N(   R   t	   text_typeR   (   R   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   N   s    (   R   R   R   t   HTTP_400_BAD_REQUESTR   R   R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR!   D   s   		t
   ParseErrorc           B  s   e  Z e j Z e d  ƒ Z RS(   u   Malformed request.(   R   R   R   R#   R   R    R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR$   R   s   	t   AuthenticationFailedc           B  s   e  Z e j Z e d  ƒ Z RS(   u%   Incorrect authentication credentials.(   R   R   R   t   HTTP_401_UNAUTHORIZEDR   R    R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR%   W   s   	t   NotAuthenticatedc           B  s   e  Z e j Z e d  ƒ Z RS(   u-   Authentication credentials were not provided.(   R   R   R   R&   R   R    R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR'   \   s   	t   PermissionDeniedc           B  s   e  Z e j Z e d  ƒ Z RS(   u2   You do not have permission to perform this action.(   R   R   R   t   HTTP_403_FORBIDDENR   R    R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR(   a   s   	t   NotFoundc           B  s   e  Z e j Z e d  ƒ Z RS(   u
   Not found.(   R   R   R   t   HTTP_404_NOT_FOUNDR   R    R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR*   f   s   	t   MethodNotAllowedc           B  s)   e  Z e j Z e d  ƒ Z d d „ Z RS(   u   Method "{method}" not allowed.c         C  s@   | d  k	 r t | ƒ |  _ n t |  j ƒ j d | ƒ |  _ d  S(   Nt   method(   R   R   R   R   t   format(   R   R-   R   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   o   s    N(	   R   R   R   t   HTTP_405_METHOD_NOT_ALLOWEDR   R    R   R   R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR,   k   s   	t   NotAcceptablec           B  s,   e  Z e j Z e d  ƒ Z d d d „ Z RS(   u,   Could not satisfy the request Accept header.c         C  s=   | d  k	 r t | ƒ |  _ n t |  j ƒ |  _ | |  _ d  S(   N(   R   R   R   R   t   available_renderers(   R   R   R1   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   z   s    N(	   R   R   R   t   HTTP_406_NOT_ACCEPTABLER   R    R   R   R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR0   v   s   	t   UnsupportedMediaTypec           B  s)   e  Z e j Z e d  ƒ Z d d „ Z RS(   u1   Unsupported media type "{media_type}" in request.c         C  s@   | d  k	 r t | ƒ |  _ n t |  j ƒ j d | ƒ |  _ d  S(   Nt
   media_type(   R   R   R   R   R.   (   R   R4   R   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   †   s    N(	   R   R   R   t   HTTP_415_UNSUPPORTED_MEDIA_TYPER   R    R   R   R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR3   ‚   s   	t	   Throttledc           B  s8   e  Z e j Z e d  ƒ Z d Z d Z d d d „ Z
 RS(   u   Request was throttled.u$   Expected available in {wait} second.u%   Expected available in {wait} seconds.c      	   C  sª   | d  k	 r t | ƒ |  _ n t |  j ƒ |  _ | d  k rH d  |  _ n^ t j | ƒ |  _ |  j d t t |  j j	 d |  j ƒ |  j
 j	 d |  j ƒ |  j ƒ ƒ 7_ d  S(   Nu    t   wait(   R   R   R   R   R7   t   matht   ceilR   t   extra_detail_singularR.   t   extra_detail_plural(   R   R7   R   (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR   •   s    N(   R   R   R   t   HTTP_429_TOO_MANY_REQUESTSR   R    R   R:   R;   R   R   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyR6      s
   	(   R   t
   __future__R    R8   t   django.utilsR   t   django.utils.encodingR   t   django.utils.translationR   R    R   t   rest_frameworkR   t'   rest_framework.utils.serializer_helpersR   R   R	   t	   ExceptionR   R!   R$   R%   R'   R(   R*   R,   R0   R3   R6   (    (    (    ss   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/exceptions.pyt   <module>   s(   	