human
Complete this python program:
def api(role):
assistant
#Here is the Python code you requested.

    """A decorator to enforce user roles in context of the API
    """
    def wrapper(handler_method):
        def check_login(self, *args, **kwargs):
            dev = os.environ['SERVER_SOFTWARE'].startswith('Development')
            host = self.request.headers.get('host', 'nohost')
            try:
                user = oauth.get_current_user()
                admin = oauth.is_current_user_admin()
            except oauth.OAuthRequestError as e:
                logging.error('OAuthRegistrationError')
                admin = False
            if (dev and (str(user) == 'example@example.com')):
                admin = True
            if (not admin):
                user = users.get_current_user()
                admin = users.is_current_user_admin()
            if (not user):
                logging.error('Unauthorized    API    access    attempt')
                self.error(403, 'Authorization    Failure')
            elif ((role == 'admin') and admin):
                logging.info('Role    is    %s    so    will    allow    handler', role)
                handler_method(self, *args, **kwargs)
            elif user:
                logging.error('User    not    in    admin    role')
                self.error(403, ('User    not    in    admin    role:    %s' % role))
            else:
                logging.error('Unknown    api    role:    %s', role)
                self.error(403, ('Unknown    api    role:    %s' % role))
        return check_login
    return wrapper