nodes: 0, module; 1, function_definition; 2, function_name:get_api_root_view; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, class_definition; 12, return_statement; 13, identifier:api_urls; 14, None; 15, comment:"""
          Return a basic root view.
          """; 16, assignment; 17, assignment; 18, pattern_list; 19, attribute; 20, block; 21, identifier:APIRootView; 22, argument_list; 23, block; 24, call; 25, identifier:api_root_dict; 26, call; 27, identifier:list_name; 28, attribute; 29, identifier:prefix; 30, identifier:viewset; 31, identifier:basename; 32, identifier:self; 33, identifier:registry; 34, expression_statement; 35, attribute; 36, expression_statement; 37, expression_statement; 38, function_definition; 39, attribute; 40, argument_list; 41, identifier:OrderedDict; 42, argument_list; 43, subscript; 44, identifier:name; 45, assignment; 46, identifier:views; 47, identifier:APIView; 48, assignment; 49, assignment; 50, function_name:get; 51, parameters; 52, comment:# Return a plain {"name": "hyperlink"} response.; 53, block; 54, identifier:APIRootView; 55, identifier:as_view; 56, attribute; 57, integer:0; 58, subscript; 59, call; 60, identifier:_ignore_model_permissions; 61, True; 62, identifier:exclude_from_schema; 63, True; 64, identifier:self; 65, identifier:request; 66, list_splat_pattern; 67, dictionary_splat_pattern; 68, expression_statement; 69, expression_statement; 70, for_statement; 71, return_statement; 72, identifier:self; 73, identifier:routes; 74, identifier:api_root_dict; 75, identifier:prefix; 76, attribute; 77, argument_list; 78, identifier:args; 79, identifier:kwargs; 80, assignment; 81, assignment; 82, pattern_list; 83, call; 84, block; 85, call; 86, identifier:list_name; 87, identifier:format; 88, keyword_argument; 89, identifier:ret; 90, call; 91, identifier:namespace; 92, attribute; 93, identifier:key; 94, identifier:url_name; 95, identifier:sorted; 96, argument_list; 97, if_statement; 98, try_statement; 99, identifier:Response; 100, argument_list; 101, identifier:basename; 102, identifier:basename; 103, identifier:OrderedDict; 104, argument_list; 105, attribute; 106, identifier:namespace; 107, call; 108, keyword_argument; 109, identifier:namespace; 110, block; 111, block; 112, except_clause; 113, identifier:ret; 114, identifier:request; 115, identifier:resolver_match; 116, attribute; 117, argument_list; 118, identifier:key; 119, call; 120, expression_statement; 121, expression_statement; 122, identifier:NoReverseMatch; 123, comment:# Don't bail out if eg. no list routes exist, only detail routes.; 124, block; 125, identifier:api_root_dict; 126, identifier:items; 127, identifier:itemgetter; 128, argument_list; 129, assignment; 130, assignment; 131, continue_statement; 132, integer:0; 133, identifier:url_name; 134, binary_operator:namespace + ':' + url_name; 135, subscript; 136, call; 137, binary_operator:namespace + ':'; 138, identifier:url_name; 139, identifier:ret; 140, identifier:key; 141, identifier:reverse; 142, argument_list; 143, identifier:namespace; 144, string; 145, identifier:url_name; 146, keyword_argument; 147, keyword_argument; 148, keyword_argument; 149, keyword_argument; 150, string_content::; 151, identifier:args; 152, identifier:args; 153, identifier:kwargs; 154, identifier:kwargs; 155, identifier:request; 156, identifier:request; 157, identifier:format; 158, call; 159, attribute; 160, argument_list; 161, identifier:kwargs; 162, identifier:get; 163, string; 164, None; 165, string_content:format
code: def get_api_root_view(self, api_urls=None):
          """
          Return a basic root view.
          """
          api_root_dict = OrderedDict()
          list_name = self.routes[0].name
          for prefix, viewset, basename in self.registry:
              api_root_dict[prefix] = list_name.format(basename=basename)
  
          class APIRootView(views.APIView):
              _ignore_model_permissions = True
              exclude_from_schema = True
  
              def get(self, request, *args, **kwargs):
                  # Return a plain {"name": "hyperlink"} response.
                  ret = OrderedDict()
                  namespace = request.resolver_match.namespace
                  for key, url_name in sorted(api_root_dict.items(), key=itemgetter(0)):
                      if namespace:
                          url_name = namespace + ':' + url_name
                      try:
                          ret[key] = reverse(
                              url_name,
                              args=args,
                              kwargs=kwargs,
                              request=request,
                              format=kwargs.get('format', None)
                          )
                      except NoReverseMatch:
                          # Don't bail out if eg. no list routes exist, only detail routes.
                          continue
  
                  return Response(ret)
  
          return APIRootView.as_view()