def get_view_introspector(api):
"""
Creates view introspector based on api
:param api:
:rtype: BaseViewIntrospector
"""
callback = api['callback']
def inmodule(callback, module_name):
return callback.__module__ == module_name
map = (
(issubclass, ViewSetMixin, ViewSetIntrospector),
(inmodule, 'rest_framework.decorators', WrappedApiViewIntrospector),
(issubclass, APIView, ApiViewIntrospector),
)
for f, param, introspector_class in map:
if f(callback, param):
return introspector_class(**api)
raise IntrospectorException('View introspector not recognized')