human
I wrote the below code

    def fdec(f):
        @wraps(f)
        def decorated(*args, **kwargs):
            if ((endpoint_class == 'resource') or (endpoint_class == 'item')):
                if args:
                    resource_name = args[0]
                elif kwargs.get('resource'):
                    resource_name = kwargs.get('resource')
                else:
                    raise ValueError(("'requires_auth(%s)'    decorated    functions    must    include    resource    in    args    or    kwargs" % endpoint_class))
                resource = app.config['DOMAIN'].get(resource_name)
                if (resource is None):
                    abort(404)
                if (endpoint_class == 'resource'):
                    public = resource['public_methods']
                    roles = list(resource['allowed_roles'])
                    if (request.method in ['GET', 'HEAD', 'OPTIONS']):
                        roles += resource['allowed_read_roles']
                    else:
                        roles += resource['allowed_write_roles']
                elif (endpoint_class == 'item'):
                    public = resource['public_item_methods']
                    roles = list(resource['allowed_item_roles'])
                    if (request.method in ['GET', 'HEAD', 'OPTIONS']):
                        roles += resource['allowed_item_read_roles']
                    else:
                        roles += resource['allowed_item_write_roles']
                auth = resource_auth(resource_name)
            else:
                resource_name = resource = None
                public = (app.config['PUBLIC_METHODS'] + ['OPTIONS'])
                roles = list(app.config['ALLOWED_ROLES'])
                if (request.method in ['GET', 'OPTIONS']):
                    roles += app.config['ALLOWED_READ_ROLES']
                else:
                    roles += app.config['ALLOWED_WRITE_ROLES']
                auth = app.auth
            if (auth and (request.method not in public)):
                if (not auth.authorized(roles,...

What's a good function header?
assistant
#Here's a good function header.

def requires_auth(endpoint_class):