import flask
from flask import request
import functools
import time
import warnings

from . import jsonify


def required_fields(fields, forbid_whitespace=False):
    '''
    Declare that the endpoint requires certain POST body fields. Without them,
    we respond with 400 and a message.

    forbid_whitespace:
        If True, then providing the field is not good enough. It must also
        contain at least some non-whitespace characters.
    '''
    def wrapper(function):
        @functools.wraps(function)
        def wrapped(*args, **kwargs):
            for requirement in fields:
                if (
                    requirement not in request.form or
                    (
                        forbid_whitespace and
                        request.form[requirement].strip() == ''
                    )
                ):
                    response = {
                        'error_type': 'MISSING_FIELDS',
                        'error_message': 'Required fields: %s' % ', '.join(fields),
                    }
                    response = jsonify.make_json_response(response, status=400)
                    return response

            return function(*args, **kwargs)
        return wrapped
    return wrapper

def not_implemented(function):
    '''
    Decorator to remember what needs doing.
    '''
    warnings.warn('%s is not implemented' % function.__name__)
    return function

def time_me(function):
    '''
    After the function is run, print the elapsed time.
    '''
    @functools.wraps(function)
    def timed_function(*args, **kwargs):
        start = time.time()
        result = function(*args, **kwargs)
        end = time.time()
        print('%s: %0.8f' % (function.__name__, end-start))
        return result
    return timed_function

@@ -601,18 +601,25 @@
         
-if
+missing =
  (%0A     
@@ -671,30 +671,9 @@
 m or
-%0A                    (
+ 
 %0A   
@@ -689,20 +689,17 @@
         
-    
+(
 forbid_w
@@ -715,32 +715,8 @@
  and
-%0A                       
  req
@@ -751,19 +751,18 @@
 () == ''
+)
 %0A
-  
         
@@ -769,18 +769,16 @@
         
-  
 )%0A      
@@ -787,17 +787,26 @@
         
-)
+if missing
 :%0A      

Make condition look better