#NEWLINE# def _setup_hooks( self , package , global_context , mods ) : #NEWLINE# #INDENT# if package . use_backends : #NEWLINE# #INDENT# if ( len ( package . use_backends ) > 1 ) : #NEWLINE# #INDENT# raise ValueError ( 'Only up to one backend supported for now' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( global_context . backend is None ) #NEWLINE# global_context . backend = load_backend ( package . use_backends [ 0 ] ) ( ) #NEWLINE# #UNINDENT# #UNINDENT# startup_hooks = find_startup_hooks ( mods ) #NEWLINE# option_hooks = find_options_hooks ( mods ) #NEWLINE# shutdown_hooks = find_shutdown_hooks ( mods ) #NEWLINE# if startup_hooks : #NEWLINE# #INDENT# startup_hooks [ 0 ] ( global_context ) #NEWLINE# #UNINDENT# if global_context . backend : #NEWLINE# #INDENT# global_context . backend . register_command_contexts ( global_context ) #NEWLINE# #UNINDENT# for command in find_command_hooks ( mods ) : #NEWLINE# #INDENT# global_context . register_command ( command . name , command ) #NEWLINE# #UNINDENT# if global_context . backend : #NEWLINE# #INDENT# global_context . backend . register_options_contexts ( global_context ) #NEWLINE# #UNINDENT# if option_hooks : #NEWLINE# #INDENT# option_hooks [ 0 ] ( global_context ) #NEWLINE# #UNINDENT# for cmd_name in global_context . command_names ( public_only = False ) : #NEWLINE# #INDENT# if ( not global_context . is_options_context_registered ( cmd_name ) ) : #NEWLINE# #INDENT# cmd = global_context . retrieve_command ( cmd_name ) #NEWLINE# context = OptionsContext . from_command ( cmd ) #NEWLINE# if ( not global_context . is_options_context_registered ( cmd_name ) ) : #NEWLINE# #INDENT# global_context . register_options_context ( cmd_name , context ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for cmd_name in global_context . command_names ( ) : #NEWLINE# #INDENT# for hook in find_pre_hooks ( startup_hooks , cmd_name ) : #NEWLINE# #INDENT# global_context . add_pre_hook ( hook , cmd_name ) #NEWLINE# #UNINDENT# for hook in find_post_hooks ( mods , cmd_name ) : #NEWLINE# #INDENT# global_context . add_post_hook ( hook , cmd_name )