
`Tc           @   sh  d  Z  d d l Z d d l Z d d l Z d d l 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 y d d l m Z Wn! e k
 r d d	 l m Z n Xd d
 l m Z d d l m Z y d d l m Z Wn! e k
 r!d d l m Z n Xd 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& m' Z' e(   Z) e* d   e j+ j, e j+ j- g D  Z. d   Z/ d   Z0 d   Z1 d   Z2 d   Z3 d d  Z4 e5 g  d  Z6 d e5 d e8 d e5 d  Z9 d   Z: d   Z; d   Z< d   Z= d  e( f d!     YZ> d" e( f d#     YZ? d S($   s   
    flask.helpers
    ~~~~~~~~~~~~~

    Implements various helpers.

    :copyright: (c) 2011 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
iN(   t   time(   t   adler32(   t   RLock(   t
   BuildError(   t   update_wrapper(   t	   url_quote(   t   quote(   t   Headers(   t   NotFound(   t	   wrap_file(   t   FileSystemLoaderi   (   t   message_flashed(   t   sessiont   _request_ctx_stackt   _app_ctx_stackt   current_appt   request(   t   string_typest	   text_typec         c   s!   |  ] } | d k r | Vq d S(   t   /N(   NR   (   t   None(   t   .0t   sep(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pys	   <genexpr>4   s    c         C   s   |  d k	 s t d   |  j S(   ss   Internal helper that returns the default endpoint for a given
    function.  This always is the function name.
    s/   expected view func if endpoint is not provided.N(   R   t   AssertionErrort   __name__(   t	   view_func(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   _endpoint_from_view_func8   s    c            sc   y t      Wn* t k
 r<   f d   } t |    SX f d   } |   } t |  | S(   s  Request contexts disappear when the response is started on the server.
    This is done for efficiency reasons and to make it less likely to encounter
    memory leaks with badly written WSGI middlewares.  The downside is that if
    you are using streamed responses, the generator cannot access request bound
    information any more.

    This function however can help you keep the context around for longer::

        from flask import stream_with_context, request, Response

        @app.route('/stream')
        def streamed_response():
            @stream_with_context
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(generate())

    Alternatively it can also be used around a specific generator::

        from flask import stream_with_context, request, Response

        @app.route('/stream')
        def streamed_response():
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(stream_with_context(generate()))

    .. versionadded:: 0.9
    c             s       } t  |  S(   N(   t   stream_with_context(   t   argst   kwargst   gen(   t   generator_or_function(    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt	   decoratorf   s    	c       
   3   st   t  j }  |  d  k r$ t d   n  |  D d  Vz x   D] } | Vq: WWd  t   d  ri   j   n  XWd  QXd  S(   Ns\   Attempted to stream with context but there was no context in the first place to keep around.t   close(   R   t   topR   t   RuntimeErrort   hasattrR!   (   t   ctxt   item(   R   (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt	   generatork   s    	(   t   itert	   TypeErrorR   t   next(   R   R    R'   t	   wrapped_g(    (   R   R   sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyR   A   s    "	
c          G   s<   |  s t  j   St |   d k r/ |  d }  n  t  j |   S(   sy  Sometimes it is necessary to set additional headers in a view.  Because
    views do not have to return response objects but can return a value that
    is converted into a response object by Flask itself, it becomes tricky to
    add headers to it.  This function can be called instead of using a return
    and you will get a response object which you can use to attach headers.

    If view looked like this and you want to add a new header::

        def index():
            return render_template('index.html', foo=42)

    You can now do something like this::

        def index():
            response = make_response(render_template('index.html', foo=42))
            response.headers['X-Parachutes'] = 'parachutes are cool'
            return response

    This function accepts the very same arguments you can return from a
    view function.  This for example creates a response with a 404 error
    code::

        response = make_response(render_template('not_found.html'), 404)

    The other use case of this function is to force the return value of a
    view function into a response which is helpful with view
    decorators::

        response = make_response(view_function())
        response.headers['X-Parachutes'] = 'parachutes are cool'

    Internally this function does the following things:

    -   if no arguments are passed, it creates a new response argument
    -   if one argument is passed, :meth:`flask.Flask.make_response`
        is invoked with it.
    -   if more than one argument is passed, the arguments are passed
        to the :meth:`flask.Flask.make_response` function as tuple.

    .. versionadded:: 0.6
    i   i    (   R   t   response_classt   lent   make_response(   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyR.      s
    *
c         K   s)  t  j } t j } | d k r- t d   n  | d k	 r | j } t j } | j j s |  d  d k r | d k	 r | |  }  q |  d }  q nH d |  k r | d k	 r | d |  }  q n |  j	 d  r |  d }  n  | j
 d t  } n6 | j } | d k rt d   n  | j
 d t  } | j
 d d  } | j
 d d  } | j
 d d  }	 | j j |  |  |	 d k	 r| st d	   n  |	 | _ n  y" | j |  | d
 | d | }
 WnD t k
 r} | | d <| | d <| | d <| j j | |  |  SX| d k	 r%|
 d t |  7}
 n  |
 S(   s  Generates a URL to the given endpoint with the method provided.

    Variable arguments that are unknown to the target endpoint are appended
    to the generated URL as query arguments.  If the value of a query argument
    is `None`, the whole pair is skipped.  In case blueprints are active
    you can shortcut references to the same blueprint by prefixing the
    local endpoint with a dot (``.``).

    This will reference the index function local to the current blueprint::

        url_for('.index')

    For more information, head over to the :ref:`Quickstart <url-building>`.

    To integrate applications, :class:`Flask` has a hook to intercept URL build
    errors through :attr:`Flask.build_error_handler`.  The `url_for` function
    results in a :exc:`~werkzeug.routing.BuildError` when the current app does
    not have a URL for the given endpoint and values.  When it does, the
    :data:`~flask.current_app` calls its :attr:`~Flask.build_error_handler` if
    it is not `None`, which can return a string to use as the result of
    `url_for` (instead of `url_for`'s default to raise the
    :exc:`~werkzeug.routing.BuildError` exception) or re-raise the exception.
    An example::

        def external_url_handler(error, endpoint, **values):
            "Looks up an external URL when `url_for` cannot build a URL."
            # This is an example of hooking the build_error_handler.
            # Here, lookup_url is some utility function you've built
            # which looks up the endpoint in some external URL registry.
            url = lookup_url(endpoint, **values)
            if url is None:
                # External lookup did not have a URL.
                # Re-raise the BuildError, in context of original traceback.
                exc_type, exc_value, tb = sys.exc_info()
                if exc_value is error:
                    raise exc_type, exc_value, tb
                else:
                    raise error
            # url_for will use this result, instead of raising BuildError.
            return url

        app.build_error_handler = external_url_handler

    Here, `error` is the instance of :exc:`~werkzeug.routing.BuildError`, and
    `endpoint` and `**values` are the arguments passed into `url_for`.  Note
    that this is for building URLs outside the current application, and not for
    handling 404 NotFound errors.

    .. versionadded:: 0.10
       The `_scheme` parameter was added.

    .. versionadded:: 0.9
       The `_anchor` and `_method` parameters were added.

    .. versionadded:: 0.9
       Calls :meth:`Flask.handle_build_error` on
       :exc:`~werkzeug.routing.BuildError`.

    :param endpoint: the endpoint of the URL (name of the function)
    :param values: the variable arguments of the URL rule
    :param _external: if set to `True`, an absolute URL is generated. Server
      address can be changed via `SERVER_NAME` configuration variable which
      defaults to `localhost`.
    :param _scheme: a string specifying the desired URL scheme. The `_external`
      parameter must be set to `True` or a `ValueError` is raised.
    :param _anchor: if provided this is added as anchor to the URL.
    :param _method: if provided this explicitly specifies an HTTP method.
    s   Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.i   t   .t	   _externals   Application was not able to create a URL adapter for request independent URL generation. You might be able to fix this by setting the SERVER_NAME config variable.t   _anchort   _methodt   _schemes/   When specifying _scheme, _external must be Truet   methodt   force_externalt   #N(   R   R"   R   R   R#   t   url_adapterR   t	   blueprintt   _is_old_modulet
   startswitht   popt   Falset   Truet   appt   inject_url_defaultst
   ValueErrort
   url_schemet   buildR   t   handle_url_build_errorR   (   t   endpointt   valuest   appctxt   reqctxR7   t   blueprint_namet   externalt   anchorR4   t   schemet   rvt   error(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   url_for   sR    E					


c         C   s   t  t j j |   j |  S(   sR  Loads a macro (or variable) a template exports.  This can be used to
    invoke a macro from within Python code.  If you for example have a
    template named `_cider.html` with the following contents:

    .. sourcecode:: html+jinja

       {% macro hello(name) %}Hello {{ name }}!{% endmacro %}

    You can access this from Python code like this::

        hello = get_template_attribute('_cider.html', 'hello')
        return hello('World')

    .. versionadded:: 0.2

    :param template_name: the name of the template
    :param attribute: the name of the variable of macro to access
    (   t   getattrR   t	   jinja_envt   get_templatet   module(   t   template_namet	   attribute(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   get_template_attribute?  s    t   messagec         C   sR   t  j d g   } | j | |  f  | t  d <t j t j   d |  d | d S(   s  Flashes a message to the next request.  In order to remove the
    flashed message from the session and to display it to the user,
    the template has to call :func:`get_flashed_messages`.

    .. versionchanged:: 0.3
       `category` parameter added.

    :param message: the message to be flashed.
    :param category: the category for the message.  The following values
                     are recommended: ``'message'`` for any kind of message,
                     ``'error'`` for errors, ``'info'`` for information
                     messages and ``'warning'`` for warnings.  However any
                     kind of string can be used as category.
    t   _flashesRV   t   categoryN(   R   t   gett   appendR   t   sendR   t   _get_current_object(   RV   RX   t   flashes(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   flashV  s
    
c            s   t  j j } | d k rF d t k r3 t j d  n g  t  j _ } n    rm t t   f d   |   } n  |  s g  | D] } | d ^ qz S| S(   s  Pulls all flashed messages from the session and returns them.
    Further calls in the same request to the function will return
    the same messages.  By default just the messages are returned,
    but when `with_categories` is set to `True`, the return value will
    be a list of tuples in the form ``(category, message)`` instead.

    Filter the flashed messages to one or more categories by providing those
    categories in `category_filter`.  This allows rendering categories in
    separate html blocks.  The `with_categories` and `category_filter`
    arguments are distinct:

    * `with_categories` controls whether categories are returned with message
      text (`True` gives a tuple, where `False` gives just the message text).
    * `category_filter` filters the messages down to only those matching the
      provided categories.

    See :ref:`message-flashing-pattern` for examples.

    .. versionchanged:: 0.3
       `with_categories` parameter added.

    .. versionchanged:: 0.9
        `category_filter` parameter added.

    :param with_categories: set to `True` to also receive categories.
    :param category_filter: whitelist of categories to limit return values
    RW   c            s   |  d   k S(   Ni    (    (   t   f(   t   category_filter(    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   <lambda>  s    i   N(   R   R"   R]   R   R   R;   t   listt   filter(   t   with_categoriesR`   R]   t   x(    (   R`   sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   get_flashed_messagess  s    .!c         C   s}  d } t |  t  r$ |  } d }	 n} d d l m }
 |  }	 t |	 d d  } | r | r t | t  r |
 t d  d d n  | r |
 t d  d d n  | d k	 r t j j	 |  s t j j
 t j |  } q n  | d k r| s | rt j | p|  d } n  | d k r&d	 } n  t   } | r| d k rq| d k r\t d
   n  t j j |  } n  | j d d d | n  t j r| r|	 d k	 r|	 j   n  | | d <t j j |  | d <d } nX |	 d k r!t | d  }	 t j j |  } t j j |  | d <n  t t j |	  } t j | d | d | d t } | d k	 rrt |  | _ n  t | j _  | d k rt j! |  } n  | d k	 r| | j _" t t#   |  | _$ n  | ry| d k	 ry| j% d t j j |  t j j |  t& t | t'  r'| j( d  n |  d @f  | ry| j) t  } | j* d k rv| j+ j, d d  qvqyn  | S(   s]  Sends the contents of a file to the client.  This will use the
    most efficient method available and configured.  By default it will
    try to use the WSGI server's file_wrapper support.  Alternatively
    you can set the application's :attr:`~Flask.use_x_sendfile` attribute
    to ``True`` to directly emit an `X-Sendfile` header.  This however
    requires support of the underlying webserver for `X-Sendfile`.

    By default it will try to guess the mimetype for you, but you can
    also explicitly provide one.  For extra security you probably want
    to send certain files as attachment (HTML for instance).  The mimetype
    guessing requires a `filename` or an `attachment_filename` to be
    provided.

    Please never pass filenames to this function from user sources without
    checking them first.  Something like this is usually sufficient to
    avoid security problems::

        if '..' in filename or filename.startswith('/'):
            abort(404)

    .. versionadded:: 0.2

    .. versionadded:: 0.5
       The `add_etags`, `cache_timeout` and `conditional` parameters were
       added.  The default behavior is now to attach etags.

    .. versionchanged:: 0.7
       mimetype guessing and etag support for file objects was
       deprecated because it was unreliable.  Pass a filename if you are
       able to, otherwise attach an etag yourself.  This functionality
       will be removed in Flask 1.0

    .. versionchanged:: 0.9
       cache_timeout pulls its default from application config, when None.

    :param filename_or_fp: the filename of the file to send.  This is
                           relative to the :attr:`~Flask.root_path` if a
                           relative path is specified.
                           Alternatively a file object might be provided
                           in which case `X-Sendfile` might not work and
                           fall back to the traditional method.  Make sure
                           that the file pointer is positioned at the start
                           of data to send before calling :func:`send_file`.
    :param mimetype: the mimetype of the file if provided, otherwise
                     auto detection happens.
    :param as_attachment: set to `True` if you want to send this file with
                          a ``Content-Disposition: attachment`` header.
    :param attachment_filename: the filename for the attachment if it
                                differs from the file's filename.
    :param add_etags: set to `False` to disable attaching of etags.
    :param conditional: set to `True` to enable conditional responses.

    :param cache_timeout: the timeout in seconds for the headers. When `None`
                          (default), this value is set by
                          :meth:`~Flask.get_send_file_max_age` of
                          :data:`~flask.current_app`.
    i(   t   warnt   names   The filename support for file objects passed to send_file is now deprecated.  Pass an attach_filename if you want mimetypes to be guessed.t
   stackleveli   s   In future flask releases etags will no longer be generated for file objects passed to the send_file function because this behavior was unreliable.  Pass filenames instead if possible, otherwise attach an etag yourself based on another valuei    s   application/octet-streams8   filename unavailable, required for sending as attachments   Content-Dispositiont
   attachmentt   filenames
   X-Sendfiles   Content-Lengtht   rbt   mimetypet   headerst   direct_passthroughs   flask-%s-%s-%ss   utf-8l    i0  s
   x-sendfileN(-   R   t
   isinstanceR   t   warningsRg   RO   t   DeprecationWarningt   ost   patht   isabst   joinR   t	   root_patht	   mimetypest
   guess_typeR   R)   t   basenamet   addt   use_x_sendfileR!   t   getsizet   opent   getmtimeR	   R   t   environR,   R=   t   intt   last_modifiedt   cache_controlt   publict   get_send_file_max_aget   max_ageR    t   expirest   set_etagR   R   t   encodet   make_conditionalt   status_codeRn   R;   (   t   filename_or_fpRm   t   as_attachmentt   attachment_filenamet	   add_etagst   cache_timeoutt   conditionalt   mtimeRk   t   fileRg   Rn   t   dataRL   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt	   send_file  s~    <	

		

			c         C   s   t  j |  } x& t D] } | | k r t    q q Wt j j |  se | d k se | j d  rq t    n  t j j |  |  S(   s6  Safely join `directory` and `filename`.

    Example usage::

        @app.route('/wiki/<path:filename>')
        def wiki_page(filename):
            filename = safe_join(app.config['WIKI_FOLDER'], filename)
            with open(filename, 'rb') as fd:
                content = fd.read() # Read and process the file content...

    :param directory: the base directory.
    :param filename: the untrusted filename relative to that directory.
    :raises: :class:`~werkzeug.exceptions.NotFound` if the resulting path
             would fall out of `directory`.
    s   ..s   ../(	   t	   posixpatht   normpatht   _os_alt_sepsR   Rs   Rt   Ru   R:   Rv   (   t	   directoryRk   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt	   safe_join.  s    c         K   sJ   t  |  |  } t j j |  s- t    n  | j d t  t | |  S(   s  Send a file from a given directory with :func:`send_file`.  This
    is a secure way to quickly expose static files from an upload folder
    or something similar.

    Example usage::

        @app.route('/uploads/<path:filename>')
        def download_file(filename):
            return send_from_directory(app.config['UPLOAD_FOLDER'],
                                       filename, as_attachment=True)

    .. admonition:: Sending files and Performance

       It is strongly recommended to activate either `X-Sendfile` support in
       your webserver or (if no authentication happens) to tell the webserver
       to serve files for the given path on its own without calling into the
       web application for improved performance.

    .. versionadded:: 0.5

    :param directory: the directory where all the files are stored.
    :param filename: the filename relative to that directory to
                     download.
    :param options: optional keyword arguments that are directly
                    forwarded to :func:`send_file`.
    R   (   R   Rs   Rt   t   isfileR   t
   setdefaultR=   R   (   R   Rk   t   options(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   send_from_directoryI  s
    c         C   s   t  j j |   } | d k	 rL t | d  rL t j j t j j | j	   St
 j |   } | d k ss |  d k r} t j   St | d  r | j |   } n t |   t  j |  j	 } t j j t j j |   S(   s   Returns the path to a package or cwd if that cannot be found.  This
    returns the path of a package or the folder that contains a module.

    Not to be confused with the package path returned by :func:`find_package`.
    t   __file__t   __main__t   get_filenameN(   t   syst   modulesRY   R   R$   Rs   Rt   t   dirnamet   abspathR   t   pkgutilt
   get_loadert   getcwdR   t
   __import__(   t   import_namet   modt   loadert   filepath(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   get_root_pathk  s    

c         C   s  |  j  d  d } t j |  } | d k s: |  d k rI t j   } n t | d  rj | j |  } n5 t | d  r | j } n t	 |   t
 j |  j } t j j t j j |   } | j |  r t j j |  } n  t j j  |  \ } } t j j t
 j  } | j |  r'| | f S| j   d k rt j j  |  \ } }	 |	 j   d k rl| }
 n9 t j j |  j   d k rt j j |  }
 n | }
 |
 | f Sd | f S(	   s  Finds a package and returns the prefix (or None if the package is
    not installed) as well as the folder that contains the package or
    module as a tuple.  The package path returned is the module that would
    have to be added to the pythonpath in order to make it possible to
    import the module.  The prefix is the path below which a UNIX like
    folder structure exists (lib, share etc.).
    R/   i    R   R   t   archives   site-packagest   libN(   t   splitR   R   R   Rs   R   R$   R   R   R   R   R   R   Rt   R   R   t
   is_packaget   prefixR:   t   lowerRz   (   R   t   root_mod_nameR   t   package_pathRk   t   site_parentt   site_foldert	   py_prefixt   parentt   foldert   base_dir(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   find_package  s4    

	
t   locked_cached_propertyc           B   s)   e  Z d  Z d d d  Z d d  Z RS(   s#  A decorator that converts a function into a lazy property.  The
    function wrapped is called the first time to retrieve the result
    and then that calculated result is used the next time you access
    the value.  Works like the one in Werkzeug but has a lock for
    thread safety.
    c         C   sI   | p | j  |  _  | j |  _ | p* | j |  _ | |  _ t   |  _ d  S(   N(   R   t
   __module__t   __doc__t   funcR   t   lock(   t   selfR   Rh   t   doc(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   __init__  s
    	c         C   sn   | d  k r |  S|  j O | j j |  j t  } | t k r` |  j |  } | | j |  j <n  | SWd  QXd  S(   N(   R   R   t   __dict__RY   R   t   _missingR   (   R   t   objt   typet   value(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   __get__  s    
N(   R   R   R   R   R   R   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyR     s   t   _PackageBoundObjectc           B   s   e  Z d d   Z d   Z d   Z e e e  Z [ [ d   Z d   Z	 e e e	  Z
 [ [	 e d    Z e d    Z d   Z d   Z d	 d
  Z RS(   c         C   s:   | |  _  | |  _ t |  j   |  _ d  |  _ d  |  _ d  S(   N(   R   t   template_folderR   Rw   R   t   _static_foldert   _static_url_path(   R   R   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyR     s
    			c         C   s,   |  j  d  k	 r( t j j |  j |  j   Sd  S(   N(   R   R   Rs   Rt   Rv   Rw   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   _get_static_folder  s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   _set_static_folder  s    c         C   s@   |  j  d  k r9 |  j d  k r" d  Sd t j j |  j  S|  j  S(   NR   (   R   R   t   static_folderRs   Rt   Rz   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   _get_static_url_path  s
    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   _set_static_url_path  s    c         C   s   |  j  d k	 S(   s   This is `True` if the package bound object's container has a
        folder named ``'static'``.

        .. versionadded:: 0.5
        N(   R   R   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   has_static_folder  s    c         C   s2   |  j  d k	 r. t t j j |  j |  j    Sd S(   sW   The Jinja loader for this package bound object.

        .. versionadded:: 0.5
        N(   R   R   R
   Rs   Rt   Rv   Rw   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   jinja_loader  s    c         C   s   t  j d S(   s  Provides default cache_timeout for the :func:`send_file` functions.

        By default, this function returns ``SEND_FILE_MAX_AGE_DEFAULT`` from
        the configuration of :data:`~flask.current_app`.

        Static file functions such as :func:`send_from_directory` use this
        function, and :func:`send_file` calls this function on
        :data:`~flask.current_app` when the given cache_timeout is `None`. If a
        cache_timeout is given in :func:`send_file`, that timeout is used;
        otherwise, this method is called.

        This allows subclasses to change the behavior when sending files based
        on the filename.  For example, to set the cache timeout for .js files
        to 60 seconds::

            class MyFlask(flask.Flask):
                def get_send_file_max_age(self, name):
                    if name.lower().endswith('.js'):
                        return 60
                    return flask.Flask.get_send_file_max_age(self, name)

        .. versionadded:: 0.9
        t   SEND_FILE_MAX_AGE_DEFAULT(   R   t   config(   R   Rk   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyR     s    c         C   s=   |  j  s t d   n  |  j |  } t |  j | d | S(   s   Function used internally to send static files from the static
        folder to the browser.

        .. versionadded:: 0.5
        s    No static folder for this objectR   (   R   R#   R   R   R   (   R   Rk   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   send_static_file*  s
    	Rl   c         C   s:   | d k r t  d   n  t t j j |  j |  |  S(   s  Opens a resource from the application's resource folder.  To see
        how this works, consider the following folder structure::

            /myapplication.py
            /schema.sql
            /static
                /style.css
            /templates
                /layout.html
                /index.html

        If you want to open the `schema.sql` file you would do the
        following::

            with app.open_resource('schema.sql') as f:
                contents = f.read()
                do_something_with(contents)

        :param resource: the name of the resource.  To access resources within
                         subfolders use forward slashes as separator.
        :param mode: resource file opening mode, default is 'rb'.
        t   rRl   s(   Resources can only be opened for reading(   R   s   rb(   R@   R~   Rs   Rt   Rv   Rw   (   R   t   resourcet   mode(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   open_resource8  s    N(   R   R   R   R   R   R   t   propertyR   R   R   t   static_url_pathR   R   R   R   R   R   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyR     s   					
		(@   R   Rs   R   R   R   Rx   R    t   zlibR   t	   threadingR   t   werkzeug.routingR   t	   functoolsR   t   werkzeug.urlsR   t   ImportErrort   urlparseR   t   werkzeug.datastructuresR   t   werkzeug.exceptionsR   t   werkzeug.wsgiR	   t   werkzeug.utilst   jinja2R
   t   signalsR   t   globalsR   R   R   R   R   t   _compatR   R   t   objectR   Rb   Rt   R   t   altsepR   R   R   R.   RN   RU   R^   R<   Rf   R   R=   R   R   R   R   R   R   R   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/helpers.pyt   <module>
   sT   (	(			H	1		'		"	!	3