#NEWLINE# def extend_resources( self , version , attr_map ) : #NEWLINE# #INDENT# 'Extend resources with additional resources or attributes.\n\n        :param attr_map: the existing mapping from resource name to\n        attrs definition.\n\n        After this function, we will extend the attr_map if an extension\n        wants to extend this map.\n        ' #NEWLINE# processed_exts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# exts_to_process = self . extensions . copy ( ) #NEWLINE# check_optionals = True #NEWLINE# while exts_to_process : #NEWLINE# #INDENT# processed_ext_count = len ( processed_exts ) #NEWLINE# for ( ext_name , ext ) in list ( exts_to_process . items ( ) ) : #NEWLINE# #INDENT# required_exts_set = set ( ext . get_required_extensions ( ) ) #NEWLINE# if ( required_exts_set - set ( processed_exts ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# optional_exts_set = set ( ext . get_optional_extensions ( ) ) #NEWLINE# if ( check_optionals and ( optional_exts_set - set ( processed_exts ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# extended_attrs = ext . get_extended_resources ( version ) #NEWLINE# for ( res , resource_attrs ) in six . iteritems ( extended_attrs ) : #NEWLINE# #INDENT# attr_map . setdefault ( res , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . update ( resource_attrs ) #NEWLINE# #UNINDENT# processed_exts [ ext_name ] = ext #NEWLINE# del exts_to_process [ ext_name ] #NEWLINE# #UNINDENT# if ( len ( processed_exts ) == processed_ext_count ) : #NEWLINE# #INDENT# if check_optionals : #NEWLINE# #INDENT# check_optionals = False #NEWLINE# continue #NEWLINE# #UNINDENT# break #NEWLINE# #UNINDENT# #UNINDENT# if exts_to_process : #NEWLINE# #INDENT# unloadable_extensions = set ( exts_to_process . keys ( ) ) #NEWLINE# LOG . error ( _LE ( 'Unable to process extensions (%s) because the configured plugins do not satisfy their requirements. Some features will not work as expected.' ) , ', ' . join ( unloadable_extensions ) ) #NEWLINE# default_extensions = set ( const . DEFAULT_SERVICE_PLUGINS . values ( ) ) #NEWLINE# if ( not ( unloadable_extensions <= default_extensions ) ) : #NEWLINE# #INDENT# raise exceptions . ExtensionsNotFound ( extensions = list ( unloadable_extensions ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ext in processed_exts . values ( ) : #NEWLINE# #INDENT# ext . update_attributes_map ( attr_map )