#NEWLINE# def _autodiscover( self ) : #NEWLINE# #INDENT# 'Discovers panels to register from the current dashboard module.' #NEWLINE# if getattr ( self , '_autodiscover_complete' , False ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# panels_to_discover = [ ] #NEWLINE# panel_groups = [ ] #NEWLINE# if all ( [ isinstance ( i , basestring ) for i in self . panels ] ) : #NEWLINE# #INDENT# self . panels = [ self . panels ] #NEWLINE# #UNINDENT# for panel_set in self . panels : #NEWLINE# #INDENT# if ( ( not isinstance ( panel_set , collections . Iterable ) ) and issubclass ( panel_set , PanelGroup ) ) : #NEWLINE# #INDENT# panel_group = panel_set ( self ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( panel_set , PanelGroup ) ) : #NEWLINE# #INDENT# panel_group = PanelGroup ( self , panels = panel_set ) #NEWLINE# #UNINDENT# #UNINDENT# panels_to_discover . extend ( panel_group . panels ) #NEWLINE# panel_groups . append ( ( panel_group . slug , panel_group ) ) #NEWLINE# #UNINDENT# self . _panel_groups = SortedDict ( panel_groups ) #NEWLINE# package = '.' . join ( self . __module__ . split ( '.' ) [ : ( - 1 ) ] ) #NEWLINE# mod = import_module ( package ) #NEWLINE# for panel in panels_to_discover : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# before_import_registry = copy . copy ( self . _registry ) #NEWLINE# import_module ( ( '.%s.panel' % panel ) , package ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . _registry = before_import_registry #NEWLINE# if module_has_submodule ( mod , panel ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _autodiscover_complete = True