
9Vc           @@  s  d  d l  m Z d  d l Z d  d l m Z m Z d  d l Z d  d l m Z m	 Z	 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 m Z m Z m Z d  d
 l m Z d  d l m Z d  d l m Z m  Z  m! Z! d  d l" m# Z# d  d l$ Z$ d  d l% m& Z& d  d l' m( Z( d  d l) Z) d d d d d d f Z* d   Z i e# d 6Z+ d e, f d     YZ- d e f d     YZ. e/ d  Z0 d e, f d     YZ1 d e, f d     YZ2 d S(   i    (   t   absolute_importN(   t   wrapst   partial(   t   requestt   url_fort   current_app(   t   abort(   t   make_response(   t
   MethodView(   t   got_request_exception(   t   HTTPExceptiont   MethodNotAllowedt   NotFoundt   NotAcceptablet   InternalServerError(   t   HTTP_STATUS_CODES(   t   Response(   t   http_status_messaget   unpackt   OrderedDict(   t   output_json(   t   _endpoint_from_view_func(   t
   MethodTypet   Apit   Resourcet   marshalt   marshal_witht   marshal_with_fieldR   c         K@  sC   y t  |   Wn. t k
 r> } t |  r8 | | _ n    n Xd S(   s   Raise a HTTPException for the given http_status_code. Attach any keyword
    arguments to the exception for later processing.
    N(   t   original_flask_abortR
   t   lent   data(   t   http_status_codet   kwargst   e(    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR      s    s   application/jsonc        	   B@  s   e  Z d  Z d d d d e e d d d  Z d   Z d   Z e d d d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sr  
    The main entry point for the application.
    You need to initialize it with a Flask Application: ::

    >>> app = Flask(__name__)
    >>> api = restful.Api(app)

    Alternatively, you can use :meth:`init_app` to set the Flask application
    after it has been constructed.

    :param app: the Flask application object
    :type app: flask.Flask
    :param prefix: Prefix all routes with a value, eg v1 or 2010-04-01
    :type prefix: str
    :param default_mediatype: The default media type to return
    :type default_mediatype: str
    :param decorators: Decorators to attach to every resource
    :type decorators: list
    :param catch_all_404s: Use :meth:`handle_error`
        to handle 404 errors throughout your app
    :param serve_challenge_on_401: Whether to serve a challenge response to
        clients on receiving 401. This usually leads to a username/password
        popup in web browers.
    :param url_part_order: A string that controls the order that the pieces
        of the url are concatenated when the full url is constructed.  'b'
        is the blueprint (or blueprint registration) prefix, 'a' is the api
        prefix, and 'e' is the path component the endpoint is added with
    :type catch_all_404s: bool
    :param errors: A dictionary to define a custom response for each
        exception or error raised during a request
    :type errors: dict

    t    s   application/jsont   baec	   	      C@  s   t  t  |  _ i  |  _ | |  _ | |  _ | r6 | n g  |  _ | |  _ | |  _ | |  _	 | pc i  |  _
 d  |  _ t   |  _ g  |  _ d  |  _ d  |  _ | d  k	 r | |  _ |  j |  n  d  S(   N(   t   dictt   DEFAULT_REPRESENTATIONSt   representationst   urlst   prefixt   default_mediatypet
   decoratorst   catch_all_404st   serve_challenge_on_401t   url_part_ordert   errorst   Nonet   blueprint_setupt   sett	   endpointst	   resourcest   appt	   blueprintt   init_app(	   t   selfR4   R(   R)   R*   R+   R,   R-   R.   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   __init__J   s"    											c         C@  sB   y | j  |  j  Wn t k
 r4 |  j |  n
 X| |  _ d S(   si  Initialize this class with the given :class:`flask.Flask`
        application or :class:`flask.Blueprint` object.

        :param app: the Flask application or blueprint object
        :type app: flask.Flask
        :type app: flask.Blueprint

        Examples::

            api = Api()
            api.add_resource(...)
            api.init_app(app)

        N(   t   recordt   _deferred_blueprint_initt   AttributeErrort	   _init_appR5   (   R7   R4   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR6   a   s
    c         @  s>   i | d 6|  j  d 6| d 6  d j   f d   |  j D  S(   si  This method is used to defer the construction of the final url in
        the case that the Api is created with a Blueprint.

        :param url_part: The part of the url the endpoint is registered with
        :param registration_prefix: The part of the url contributed by the
            blueprint.  Generally speaking, BlueprintSetupState.url_prefix
        t   bt   aR!   R"   c         3@  s#   |  ] }   | r   | Vq d  S(   N(    (   t   .0t   key(   t   parts(    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pys	   <genexpr>   s    (   R(   t   joinR-   (   R7   t   url_partt   registration_prefix(    (   RA   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   _complete_urly   s
    

c         K@  s   t  |  r | |  j  } n |  j r7 |  j | } n  | j d |  j  | d k re t |  } n  |  j } d | k r t | | j d   } n  |  j	 j
 | d |  j j | f | d | | d S(   sw  Method used to patch BlueprintSetupState.add_url_rule for setup
        state instance corresponding to this Api instance.  Exists primarily
        to enable _complete_url's function.

        :param blueprint_setup: The BlueprintSetupState instance (self)
        :param rule: A string or callable that takes a string and returns a
            string(_complete_url) that is the url rule for the endpoint
            being registered
        :param endpoint: See BlueprintSetupState.add_url_rule
        :param view_func: See BlueprintSetupState.add_url_rule
        :param **options: See BlueprintSetupState.add_url_rule
        t	   subdomaint   defaultss   %s.%sN(   t   callablet
   url_prefixt
   setdefaultRF   R/   R   t   url_defaultsR$   t   popR4   t   add_url_ruleR5   t   name(   R0   t   rulet   endpointt	   view_funct   optionsRG   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt#   _blueprint_setup_add_url_rule_patch   s    		c         C@  sk   | |  _  | j j d k r? | j | _ t t j |  | _ n  | j sW t d   n  |  j	 | j
  d S(   s  Synchronize prefix between blueprint/api and registration options, then
        perform initialization with setup_state.app :class:`flask.Flask` object.
        When a :class:`flask_restful.Api` object is initialized with a blueprint,
        this method is recorded on the blueprint to be run when the blueprint is later
        registered to a :class:`flask.Flask` object.  This method also monkeypatches
        BlueprintSetupState.add_url_rule with _blueprint_setup_add_url_rule_patch.

        :param setup_state: The setup state object passed to deferred functions
            during blueprint registration
        :type setup_state: flask.blueprints.BlueprintSetupState

        RS   s5   flask-restful blueprints can only be registered once.N(   R0   RM   t   __name__t   _original_add_url_ruleR   R   RS   t   first_registrationt
   ValueErrorR<   R4   (   R7   t   setup_state(    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR:      s    			c         C@  s   t  |  j | j  | _ t  |  j | j  | _ t |  j  d k r{ x3 |  j D]% \ } } } |  j | | | |  qO Wn  d S(   s   Perform initialization actions with the given :class:`flask.Flask`
        object.

        :param app: The flask application object
        :type app: flask.Flask
        i    N(   R   t   error_routert   handle_exceptiont   handle_user_exceptionR   R3   t   _register_view(   R7   R4   t   resourceR'   R    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR<      s
    c         C@  sU   |  j  rH | j |  j  j  rA | j |  j  j d d  d } qH t Sn  | |  j k S(   s   Tests if an endpoint name (not path) belongs to this Api.  Takes
        in to account the Blueprint name part of the endpoint name.

        :param endpoint: The name of the endpoint being checked
        :return: bool
        t   .i   i(   R5   t
   startswithRN   t   splitt   FalseR2   (   R7   RP   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   owns_endpoint   s
    	#c         C@  s   t  j t  } y | j   Wne t k
 rj } | j d } | j d | d t  \ } } |  j | j  St	 k
 r~ |  j
 Sn Xd S(   s-   Determine if error should be handled with FR or default Flask

        The goal is to return Flask error handlers for non-FR-related routes,
        and FR errors (with the correct media type) for FR endpoints. This
        method currently handles 404 and 405 errors.

        :return: bool
        i    t   methodt   return_ruleN(   R   t   create_url_adapterR   t   matchR   t   valid_methodst   TrueRb   RP   R   R+   (   R7   t   adapterR!   t   valid_route_methodRO   t   _(    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   _should_use_fr_error_handler   s    	c         C@  s0   |  j    r t St j s t S|  j t j j  S(   sG   Encapsulating the rules for whether the request was to a Flask endpoint(   Rl   Rh   R   t   url_ruleRa   Rb   RP   (   R7   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   _has_fr_route   s
    	c         C@  s>   |  j    r4 y |  j |  SWq4 t k
 r0 q4 Xn  | |  S(   s  This function decides whether the error occured in a flask-restful
        endpoint or not. If it happened in a flask-restful endpoint, our
        handler will be dispatched. If it happened in an unrelated view, the
        app's original error handler will be dispatched.
        In the event that the error occurred in a flask-restful endpoint but
        the local handler can't resolve the situation, the router will fall
        back onto the original_handler as last resort.

        :param original_handler: the original Flask error handler for the app
        :type original_handler: function
        :param e: the exception raised while handling the request
        :type e: Exception

        (   Rn   t   handle_errort	   Exception(   R7   t   original_handlerR!   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyRY      s    c      	   @  s  t  j t j   d | t | t  rb t j rb t j   \ } } } | | k rY   qb |  n  t | t  r | j	 } i t
 | d t |   d 6} n d } i t |  d 6} t
 | d |  } i  } | d k rt j   d k r t j j d  qt j j d  n  t j j d t  }	 | d k r|	 rt g  t j j   D]' }
 t j d	 d
 |
 j  |
 j f ^ qK   t j t j   j    } | rd | k r| d j d  d | d <n
 d
 | d <| d c d t j d d j   f d   | D  d 7<qn  | d k r.| j  | d <n  t! |  j" } | |  j# k r|  j# j | i   } | j d d  } | j$ |  n  | d k r|  j% d k rt& |  j' j    } | r| d n d } |  j( | | | d | } n |  j( | | |  } | d k r|  j) |  } n  | S(   s   Error handler for the API transforms a raised exception into a Flask
        response, with the appropriate HTTP status code and body.

        :param e: the raised Exception object
        :type e: Exception

        t	   exceptiont   descriptiont   messagei  R   s   Internal Errort   ERROR_404_HELPi  s   (<.*>)R"   R^   s   . s   You have requested this URI [s   ] but did you mean s    or c         3@  s   |  ] }   | Vq d  S(   N(    (   R?   Rf   (   t   rules(    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pys	   <genexpr>F  s    s    ?i  t   Allowt   statusi  i    s
   text/plaint   fallback_mediatypei  N(   NNN(*   R	   t   sendR   t   _get_current_objectt
   isinstanceR
   t   propagate_exceptionst   syst   exc_infot   codet   getattrR   R/   t   loggert   errorRr   t   configt   getRh   R$   t   url_mapt
   iter_rulest   ret   subRO   t   difflibt   get_close_matchesR   t   patht   keyst   rstripRB   Rg   t   typeRT   R.   t   updateR)   t   listR&   R   t   unauthorized(   R7   R!   t   exc_typet	   exc_valuet   tbR   t   default_dataR   t   headerst   help_on_404RO   t   close_matchest   error_cls_namet   custom_datat   supported_mediatypesRy   t   resp(    (   Rv   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyRo     sb    		=

8c         @  s     f d   S(   s:   Return a method that returns a list of mediatypes
        c         @  s     j      j g S(   N(   t
   mediatypesR)   (   t   resource_cls(   R7   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   <lambda>i  s    (    (   R7   (    (   R7   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   mediatypes_methodf  s    c         O@  sH   |  j  d k	 r+ |  j |  j  | | |  n |  j j | | | f  d S(   s  Adds a resource to the api.

        :param resource: the class name of your resource
        :type resource: :class:`Resource`
        :param urls: one or more url routes to match for the resource, standard
                     flask routing rules apply.  Any url variables will be
                     passed to the resource method as args.
        :type urls: str

        :param endpoint: endpoint name (defaults to :meth:`Resource.__name__.lower`
            Can be used to reference this route in :class:`fields.Url` fields
        :type endpoint: str

        :param resource_class_args: args to be forwarded to the constructor of
            the resource.
        :type resource_class_args: tuple

        :param resource_class_kwargs: kwargs to be forwarded to the constructor
            of the resource.
        :type resource_class_kwargs: dict

        Additional keyword arguments not specified above will be passed as-is
        to :meth:`flask.Flask.add_url_rule`.

        Examples::

            api.add_resource(HelloWorld, '/', '/hello')
            api.add_resource(Foo, '/foo', endpoint="foo")
            api.add_resource(FooSpecial, '/special/foo', endpoint="foo")

        N(   R4   R/   R\   R3   t   append(   R7   R]   R'   R    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   add_resourcek  s     c         @  s       f d   } | S(   s  Wraps a :class:`~flask_restful.Resource` class, adding it to the
        api. Parameters are the same as :meth:`~flask_restful.Api.add_resource`.

        Example::

            app = Flask(__name__)
            api = restful.Api(app)

            @api.resource('/foo')
            class Foo(Resource):
                def get(self):
                    return 'Hello, World!'

        c         @  s    j  |      |  S(   N(   R   (   t   cls(   R    R7   R'   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt	   decorator  s    (    (   R7   R'   R    R   (    (   R    R7   R'   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR]     s    c         O@  s  | j  d d   p | j j   } |  j j |  | j  d d  } | j  d i   } | | j j   k r | j | j d } | | k r t	 d | | j f   q n  |  j
   | _ | | _ |  j | j | | |   }	 x |  j D] }
 |
 |	  }	 q Wx| | D]t } |  j rR|  j r=|  j j | d |	 | qqdt |  j |  } n |  j | d  } | j | d |	 | qWd  S(	   NRP   t   resource_class_argst   resource_class_kwargst
   view_classs2   This endpoint (%s) is already set to the class %s.RQ   R"   (    (   RL   R/   RT   t   lowerR2   t   addt   view_functionsR   t   __dict__RW   R   R   RP   t   outputt   as_viewR*   R5   R0   RM   R   RE   (   R7   R4   R]   R'   R    RP   R   R   t   previous_view_classt   resource_funcR   t   urlRO   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR\     s,    !			c         @  s"   t        f d    } | S(   s   Wraps a resource (as a flask view function), for cases where the
        resource does not directly return a response object

        :param resource: The resource as a flask view function
        c          @  sM     |  |   } t  | t  r" | St |  \ } } }  j | | d | S(   NR   (   R|   t   ResponseBaseR   R   (   t   argsR    R   R   R   R   (   R]   R7   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   wrapper  s
    (   R   (   R7   R]   R   (    (   R]   R7   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s    c         K@  s:   | j  } |  j r- d j |  j j |  } n  t | |  S(   sQ   Generates a URL to the given resource.

        Works like :func:`flask.url_for`.s   {0}.{1}(   RP   R5   t   formatRN   R   (   R7   R]   t   valuesRP   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s    		c         O@  s   | j  d d  p |  j } t j j |  j d | } | d k rN t    n  | |  j k r |  j | | | |  } | | j d <| S| d k r t	 t
 |  | |  } d | j d <| St    d S(   s  Looks up the representation transformer for the requested media
        type, invoking the transformer to create a response object. This
        defaults to default_mediatype if no transformer is found for the
        requested mediatype. If default_mediatype is None, a 406 Not
        Acceptable response will be sent as per RFC 2616 section 14.1

        :param data: Python object containing response data to be transformed
        Ry   t   defaults   Content-Types
   text/plainN(   RL   R/   R)   R   t   accept_mimetypest
   best_matchR&   R   R   t   original_flask_make_responset   strR   (   R7   R   R   R    R)   t	   mediatypeR   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s    				c         C@  s;   g  t  t j d t j d  d t D] \ } } | ^ q% S(   s@   Returns a list of requested mediatypes sent in the Accept headerR@   i   t   reverse(   t   sortedR   R   t   operatort
   itemgetterRh   (   R7   t   ht   q(    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s    c         @  s      f d   } | S(   s  Allows additional representation transformers to be declared for the
        api. Transformers are functions that must be decorated with this
        method, passing the mediatype the transformer represents. Three
        arguments are passed to the transformer:

        * The data to be represented in the response body
        * The http status code
        * A dictionary of headers

        The transformer should convert the data appropriately for the mediatype
        and return a Flask response object.

        Ex::

            @api.representation('application/xml')
            def xml(data, code, headers):
                resp = make_response(convert_data_to_xml(data), code)
                resp.headers.extend(headers)
                return resp
        c         @  s   |   j    <|  S(   N(   R&   (   t   func(   R   R7   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s    (    (   R7   R   R   (    (   R   R7   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   representation  s    c         C@  sD   |  j  r@ t j j d d  } d j d |  } | | j d <n  | S(   s4    Given a response, change it to ask for credentials t   HTTP_BASIC_AUTH_REALMs   flask-restfulu   {0} realm="{1}"t   Basics   WWW-Authenticate(   R,   R   R   R   R   R   (   R7   t   responset   realmt	   challenge(    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR   !  s
    	N(   RT   t
   __module__t   __doc__R/   Ra   R8   R6   RE   t   staticmethodRS   R:   R<   Rb   Rl   Rn   RY   Ro   R   R   R]   R\   R   R   R   R   R   R   (    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR   '   s4   !							
		V		%		+						c           B@  s#   e  Z d  Z d Z g  Z d   Z RS(   s  
    Represents an abstract RESTful resource. Concrete resources should
    extend from this class and expose methods for each supported HTTP
    method. If a resource is invoked with an unsupported HTTP method,
    the API will return a response with status 405 Method Not Allowed.
    Otherwise the appropriate method is called and passed all arguments
    from the url rule used when adding the resource to an Api instance. See
    :meth:`~flask_restful.Api.add_resource` for details.
    c         O@  s  t  |  t j j   d   } | d  k rK t j d k rK t  |  d d   } n  | d  k	 sj t d t j   x |  j D] } | |  } qt W| | |   } t | t  r | S|  j	 p i  } t j
 j | d d  } | | k rt |  \ } }	 }
 | | | |	 |
  } | | j d <| S| S(   Nt   HEADR   s   Unimplemented method %rR   s   Content-Type(   R   R   Rc   R   R/   t   AssertionErrort   method_decoratorsR|   R   R&   R   R   R   R   (   R7   R   R    t   methR   R   R&   R   R   R   R   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   dispatch_request9  s"    N(   RT   R   R   R/   R&   R   R   (    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR   ,  s   	c         @  s   d    t    t t f  rs | rS t | g    D] } t | |  ^ q1 f g  Sg    D] } t | |  ^ qZ S   f d   | j   D } | r t | t |  f g  St |  S(   s  Takes raw data (in the form of a dict, list, object) and a dict of
    fields to output and filters the data based on those fields.

    :param data: the actual object(s) from which the fields are taken from
    :param fields: a dict of whose keys will make up the final serialized
                   response output
    :param envelope: optional key that will be used to envelop the serialized
                     response


    >>> from flask_restful import fields, marshal
    >>> data = { 'a': 100, 'b': 'foo' }
    >>> mfields = { 'a': fields.Raw }

    >>> marshal(data, mfields)
    OrderedDict([('a', 100)])

    >>> marshal(data, mfields, envelope='data')
    OrderedDict([('data', OrderedDict([('a', 100)]))])

    c         S@  s   t  |  t  r |    S|  S(   N(   R|   R   (   R   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   maken  s    c         3@  sQ   |  ]G \ } } | t  | t  r0 t   |  n  |  j |    f Vq d  S(   N(   R|   R$   R   R   (   R?   t   kt   v(   R   R   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pys	   <genexpr>w  s   (   R|   R   t   tupleR   R   t   items(   R   t   fieldst   envelopet   dR   (    (   R   R   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR   W  s    	Uc           B@  s#   e  Z d  Z d d  Z d   Z RS(   s1  A decorator that apply marshalling to the return values of your methods.

    >>> from flask_restful import fields, marshal_with
    >>> mfields = { 'a': fields.Raw }
    >>> @marshal_with(mfields)
    ... def get():
    ...     return { 'a': 100, 'b': 'foo' }
    ...
    ...
    >>> get()
    OrderedDict([('a', 100)])

    >>> @marshal_with(mfields, envelope='data')
    ... def get():
    ...     return { 'a': 100, 'b': 'foo' }
    ...
    ...
    >>> get()
    OrderedDict([('data', OrderedDict([('a', 100)]))])

    see :meth:`flask_restful.marshal`
    c         C@  s   | |  _  | |  _ d S(   s   
        :param fields: a dict of whose keys will make up the final
                       serialized response output
        :param envelope: optional key that will be used to envelop the serialized
                         response
        N(   R   R   (   R7   R   R   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR8     s    	c         @  s"   t        f d    } | S(   Nc          @  sl     |  |   } t  | t  rR t |  \ } } } t |  j  j  | | f St |  j  j  Sd  S(   N(   R|   R   R   R   R   R   (   R   R    R   R   R   R   (   t   fR7   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s
    (   R   (   R7   R   R   (    (   R   R7   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   __call__  s    N(   RT   R   R   R/   R8   R   (    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR   }  s   
c           B@  s    e  Z d  Z d   Z d   Z RS(   sT  
    A decorator that formats the return values of your methods with a single field.

    >>> from flask_restful import marshal_with_field, fields
    >>> @marshal_with_field(fields.List(fields.Integer))
    ... def get():
    ...     return ['1', 2, 3.0]
    ...
    >>> get()
    [1, 2, 3]

    see :meth:`flask_restful.marshal_with`
    c         C@  s+   t  | t  r |   |  _ n	 | |  _ d S(   sP   
        :param field: a single field with which to marshal the output.
        N(   R|   R   t   field(   R7   R   (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR8     s    c         @  s"   t        f d    } | S(   Nc          @  s\     |  |   } t  | t  rL t |  \ } } }  j j |  | | f S j j |  S(   N(   R|   R   R   R   R   (   R   R    R   R   R   R   (   R   R7   (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s
    (   R   (   R7   R   R   (    (   R   R7   s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s    	(   RT   R   R   R8   R   (    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyR     s   		(3   t
   __future__R    R   t	   functoolsR   R   R   t   flaskR   R   R   R   R   R   R   t   flask.viewsR   t   flask.signalsR	   t   werkzeug.exceptionsR
   R   R   R   R   t   werkzeug.httpR   t   werkzeug.wrappersR   R   t   flask_restful.utilsR   R   R   t"   flask_restful.representations.jsonR   R~   t   flask.helpersR   t   typesR   R   t   __all__R%   t   objectR   R   R/   R   R   R   (    (    (    s=   /tmp/pip-build-Q6F9ld/flask-restful/flask_restful/__init__.pyt   <module>   s6   (	  +&-