#NEWLINE# def _GetVersionsPerM4Scripts( self , projects ) : #NEWLINE# #INDENT# 'Retrieves the versions per m4 script.\n\n    Args:\n      projects: a list of project objects (instances of Project).\n\n    Returns:\n      A dictionary containing the m4 scripts, their versions and the\n      the names of the project that use the specific version. In the form:\n      { m4_script_name: { m4_script_version: [ project_name, ... ], ... }, ... }\n    ' #NEWLINE# projects_path = os . path . dirname ( self . _data_directory ) #NEWLINE# projects_path = os . path . dirname ( projects_path ) #NEWLINE# m4_script_glob = os . path . join ( self . _data_directory , 'm4' , '*.m4' ) #NEWLINE# versions_per_m4_script = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for path in glob . glob ( m4_script_glob ) : #NEWLINE# #INDENT# m4_script_file = M4ScriptFile ( path ) #NEWLINE# version = None #NEWLINE# logging . info ( 'Reading: {0:s}' . format ( path ) ) #NEWLINE# if m4_script_file . ReadVersion ( ) : #NEWLINE# #INDENT# version = m4_script_file . version #NEWLINE# #UNINDENT# if ( not version ) : #NEWLINE# #INDENT# version = 'missing' #NEWLINE# #UNINDENT# versions_per_m4_script [ m4_script_file . name ] = { #NEWLINE# #INDENT# version : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# for project in projects : #NEWLINE# #INDENT# project_m4_scripts_path = os . path . join ( projects_path , project . name , 'm4' ) #NEWLINE# for m4_script in versions_per_m4_script . keys ( ) : #NEWLINE# #INDENT# m4_script_path = os . path . join ( project_m4_scripts_path , m4_script ) #NEWLINE# if ( not os . path . exists ( m4_script_path ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# m4_script_file = M4ScriptFile ( m4_script_path ) #NEWLINE# version = None #NEWLINE# logging . info ( 'Reading: {0:s}' . format ( m4_script_path ) ) #NEWLINE# if m4_script_file . ReadVersion ( ) : #NEWLINE# #INDENT# version = m4_script_file . version #NEWLINE# #UNINDENT# if ( not version ) : #NEWLINE# #INDENT# version = 'missing' #NEWLINE# #UNINDENT# projects_per_version = versions_per_m4_script [ m4_script ] #NEWLINE# if ( version not in projects_per_version ) : #NEWLINE# #INDENT# projects_per_version [ version ] = [ ] #NEWLINE# #UNINDENT# projects_per_version [ version ] . append ( project . name ) #NEWLINE# #UNINDENT# #UNINDENT# return versions_per_m4_script