ķ
ž^Yc           @@  s  d  Z  d d l m Z d Z d d l Z y d d l m Z Wn! e k
 r_ d d l m Z n Xd 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 e f d     YZ d e
 f d      YZ d! e
 f d"     YZ d S(#   s_   Errors for the library.

All exceptions defined by the library
should be defined in this file.
i    (   t   absolute_imports$   jcgregorio@google.com (Joe Gregorio)N(   t   util(   t   _helperst   Errorc           B@  s   e  Z d  Z RS(   s   Base error for this module.(   t   __name__t
   __module__t   __doc__(    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR   "   s   t	   HttpErrorc           B@  sA   e  Z d  Z e j d  d d   Z d   Z d   Z e Z	 RS(   s$   HTTP data was invalid or unexpected.i   c         C@  s=   | |  _  t | t  s' t d   n  | |  _ | |  _ d  S(   Ns   HTTP content should be bytes(   t   respt
   isinstancet   bytest	   TypeErrort   contentt   uri(   t   selfR   R   R   (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyt   __init__*   s
    		c         C@  sŊ   |  j  j } y{ t j |  j j d   } t | t  rJ | d d } n< t | t  r t	 |  d k r | d } | d d } n  Wn t
 t t f k
 rŖ n X| d k rš d } n  | S(   s=   Calculate the reason for the error from the response content.s   utf-8t   errort   messagei    t    N(   R   t   reasont   jsont   loadsR   t   decodeR	   t   dictt   listt   lent
   ValueErrort   KeyErrorR   t   None(   R   R   t   datat   first_error(    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyt   _get_reason2   s    !
	c         C@  sM   |  j  r/ d |  j j |  j  |  j   j   f Sd |  j j |  j   f Sd  S(   Ns/   <HttpError %s when requesting %s returned "%s">s   <HttpError %s "%s">(   R   R   t   statusR   t   strip(   R   (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyt   __repr__B   s    	#N(
   R   R   R   R   t
   positionalR   R   R   R"   t   __str__(    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR   '   s   		t   InvalidJsonErrorc           B@  s   e  Z d  Z RS(   s&   The JSON returned could not be parsed.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR%   L   s   t   UnknownFileTypec           B@  s   e  Z d  Z RS(   s    File type unknown or unexpected.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR&   Q   s   t   UnknownLinkTypec           B@  s   e  Z d  Z RS(   s    Link type unknown or unexpected.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR'   V   s   t   UnknownApiNameOrVersionc           B@  s   e  Z d  Z RS(   s)   No API with that name and version exists.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR(   [   s   t   UnacceptableMimeTypeErrorc           B@  s   e  Z d  Z RS(   s4   That is an unacceptable mimetype for this operation.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR)   `   s   t   MediaUploadSizeErrorc           B@  s   e  Z d  Z RS(   s+   Media is larger than the method can accept.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR*   e   s   t   ResumableUploadErrorc           B@  s   e  Z d  Z RS(   s&   Error occured during resumable upload.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR+   j   s   t   InvalidChunkSizeErrorc           B@  s   e  Z d  Z RS(   s!   The given chunksize is not valid.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR,   o   s   t   InvalidNotificationErrorc           B@  s   e  Z d  Z RS(   s$   The channel Notification is invalid.(   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR-   s   s   t
   BatchErrorc           B@  s;   e  Z d  Z e j d  d d d   Z d   Z e Z RS(   s&   Error occured during batch operations.i   c         C@  s   | |  _  | |  _ | |  _ d  S(   N(   R   R   R   (   R   R   R   R   (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR   z   s    		c         C@  sA   t  |  j d d   d  k r& d |  j Sd |  j j |  j f Sd  S(   NR    s   <BatchError "%s">s   <BatchError %s "%s">(   t   getattrR   R   R   R    (   R   (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR"      s    N(	   R   R   R   R   R#   R   R   R"   R$   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR.   w   s
   	t   UnexpectedMethodErrorc           B@  s)   e  Z d  Z e j d  d d   Z RS(   s;   Exception raised by RequestMockBuilder on unexpected calls.i   c         C@  s   t  t |   j d |  d S(   s)   Constructor for an UnexpectedMethodError.s   Received unexpected call %sN(   t   superR0   R   (   R   t   methodId(    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR      s    N(   R   R   R   R   R#   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR0      s   t   UnexpectedBodyErrorc           B@  s   e  Z d  Z d   Z RS(   s<   Exception raised by RequestMockBuilder on unexpected bodies.c         C@  s$   t  t |   j d | | f  d S(   s)   Constructor for an UnexpectedMethodError.s   Expected: [%s] - Provided: [%s]N(   R1   R3   R   (   R   t   expectedt   provided(    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR      s    (   R   R   R   R   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyR3      s   (   R   t
   __future__R    t
   __author__R   t   oauth2clientR   t   ImportErrorR   t	   ExceptionR   R   R%   R&   R'   R(   R)   R*   R+   R,   R-   R.   R0   R3   (    (    (    sH   /tmp/pip-build-kpPAdC/google-api-python-client/googleapiclient/errors.pyt   <module>   s*   %
