nodes: 0, module; 1, function_definition; 2, function_name:get_enabled_plugins; 3, parameters; 4, block; 5, expression_statement; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, string; 11, assignment; 12, assignment; 13, identifier:plugin; 14, identifier:plugins; 15, block; 16, list_comprehension; 17, string_content:Returns enabled preview plugins.
  
      Plugins are sorted, defaults come last; 18, identifier:plugins; 19, call; 20, identifier:valid; 21, list_comprehension; 22, if_statement; 23, call; 24, for_in_clause; 25, attribute; 26, argument_list; 27, identifier:p; 28, for_in_clause; 29, if_clause; 30, comparison_operator:plugin not in valid; 31, block; 32, identifier:p; 33, argument_list; 34, identifier:p; 35, call; 36, call; 37, identifier:values; 38, identifier:p; 39, identifier:plugins; 40, call; 41, identifier:plugin; 42, identifier:valid; 43, expression_statement; 44, expression_statement; 45, expression_statement; 46, identifier:sorted; 47, argument_list; 48, attribute; 49, argument_list; 50, identifier:issubclass; 51, argument_list; 52, assignment; 53, assignment; 54, call; 55, identifier:valid; 56, keyword_argument; 57, identifier:entrypoints; 58, identifier:get_enabled; 59, string; 60, identifier:current_app; 61, identifier:p; 62, identifier:PreviewPlugin; 63, identifier:clsname; 64, attribute; 65, identifier:msg; 66, call; 67, attribute; 68, argument_list; 69, identifier:key; 70, lambda; 71, string_content:udata.preview; 72, identifier:plugin; 73, identifier:__name__; 74, attribute; 75, argument_list; 76, identifier:warnings; 77, identifier:warn; 78, identifier:msg; 79, identifier:PreviewWarning; 80, lambda_parameters; 81, conditional_expression:1 if p.fallback else 0; 82, string; 83, identifier:format; 84, identifier:clsname; 85, identifier:p; 86, integer:1; 87, attribute; 88, integer:0; 89, string_content:{0} is not a valid preview plugin; 90, identifier:p; 91, identifier:fallback
code: def get_enabled_plugins():
      '''
      Returns enabled preview plugins.
  
      Plugins are sorted, defaults come last
      '''
      plugins = entrypoints.get_enabled('udata.preview', current_app).values()
      valid = [p for p in plugins if issubclass(p, PreviewPlugin)]
      for plugin in plugins:
          if plugin not in valid:
              clsname = plugin.__name__
              msg = '{0} is not a valid preview plugin'.format(clsname)
              warnings.warn(msg, PreviewWarning)
      return [p() for p in sorted(valid, key=lambda p: 1 if p.fallback else 0)]