#NEWLINE# def loadHooks( self ) : #NEWLINE# #INDENT# target = self . target #NEWLINE# config = self . target . config #NEWLINE# lib = self . target . library #NEWLINE# platform = self . target . project . platform #NEWLINE# for fileName in config . get ( 'hooks' , [ ] ) : #NEWLINE# #INDENT# Log . notice ( ( "Parsing hooks from '%s'." % fileName ) ) #NEWLINE# source = self . readSource ( fileName ) #NEWLINE# functions = Parser . parseSource ( source ) . functions . values ( ) #NEWLINE# if ( not functions ) : #NEWLINE# #INDENT# Log . warn ( 'No hooks found.' ) #NEWLINE# #UNINDENT# for f in p : #NEWLINE# #INDENT# Log . debug ( ( '%s %s(%s)' % ( f . type , f . name , ', ' . join ( [ ( '%s %s' % ( t . type , p ) ) for ( p , t ) in f . parameters . items ( ) ] ) ) ) ) #NEWLINE# #UNINDENT# for function in functions : #NEWLINE# #INDENT# if ( not function . body ) : #NEWLINE# #INDENT# Log . warn ( ( "Hook function '%s' has no body." % function . name ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if function . name . startswith ( '@' ) : #NEWLINE# #INDENT# lib . hooks [ function . name ] = function . body #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( name , hookName ) = function . name . split ( '.' , 1 ) #NEWLINE# if ( not ( name in lib . functions ) ) : #NEWLINE# #INDENT# target . fail ( ( "Function '%s' referred by hook function '%s' does not exist." % ( name , function . name ) ) ) #NEWLINE# #UNINDENT# if ( ( not hookName . startswith ( '@' ) ) and ( not ( hookName in lib . functions [ name ] . parameters ) ) ) : #NEWLINE# #INDENT# target . fail ( ( "Parameter '%s' referred by hook function '%s' does not exist." % ( hookName , function . name ) ) ) #NEWLINE# #UNINDENT# lib . functions [ name ] . hooks [ hookName ] = function . body #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# target . fail ( ( "Hook function name '%s' is not valid." % function . name ) )