<s> """<STR_LIT>""" <EOL> import sys <EOL> from inspect import getmembers , getmodule , isclass <EOL> from . handlers import handler <EOL> from . utils import safeimport <EOL> from . components import BaseComponent <EOL> class Loader ( BaseComponent ) : <EOL> """<STR_LIT>""" <EOL> channel = "<STR_LIT>" <EOL> def __init__ ( self , auto_register = True , init_args = None , <EOL> init_kwargs = None , paths = None , channel = channel ) : <EOL> "<STR_LIT>" <EOL> super ( Loader , self ) . __init__ ( channel = channel ) <EOL> self . _auto_register = auto_register <EOL> self . _init_args = init_args or tuple ( ) <EOL> self . _init_kwargs = init_kwargs or dict ( ) <EOL> if paths : <EOL> for path in paths : <EOL> sys . path . insert ( <NUM_LIT:0> , path ) <EOL> @ handler ( "<STR_LIT>" ) <EOL> def load ( self , name ) : <EOL> module = safeimport ( name ) <EOL> if module is not None : <EOL> test = lambda x : isclass ( x ) and issubclass ( x , BaseComponent ) and getmodule ( x ) is module <EOL> components = [ x [ <NUM_LIT:1> ] for x in getmembers ( module , test ) ] <EOL> if components : <EOL> TheComponent = components [ <NUM_LIT:0> ] <EOL> component = TheComponent ( <EOL> * self . _init_args , <EOL> ** self . _init_kwargs <EOL> ) <EOL> if self . _auto_register : <EOL> component . register ( self ) <EOL> return component </s>
