#NEWLINE# def load( path , distros_patch = None ) : #NEWLINE# #INDENT# 'Load configuration for all distros found in path.\n\n    :param path: path containing distro configuration in yaml format\n    :param distros_patch: distros file patch, jsonpath format (rfc6902)\n    ' #NEWLINE# distro_possibles = [ ] #NEWLINE# patch = ( jsonpatch . JsonPatch ( distros_patch ) if distros_patch else None ) #NEWLINE# input_files = glob . glob ( sh . joinpths ( path , '*.yaml' ) ) #NEWLINE# if ( not input_files ) : #NEWLINE# #INDENT# raise excp . ConfigException ( ( 'Did not find any distro definition files in %r' % path ) ) #NEWLINE# #UNINDENT# for fn in input_files : #NEWLINE# #INDENT# LOG . debug ( 'Attempting to load distro definition from %r' , fn ) #NEWLINE# try : #NEWLINE# #INDENT# cls_kvs = utils . load_yaml ( fn ) #NEWLINE# if patch : #NEWLINE# #INDENT# patch . apply ( distros_patch , in_place = True ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# LOG . warning ( 'Could not load distro definition from %r: %s' , fn , err ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'name' not in cls_kvs ) : #NEWLINE# #INDENT# ( name , _ext ) = os . path . splitext ( sh . basename ( fn ) ) #NEWLINE# cls_kvs [ 'name' ] = name #NEWLINE# #UNINDENT# distro_possibles . append ( Distro ( ** cls_kvs ) ) #NEWLINE# #UNINDENT# #UNINDENT# matches = _match_distros ( distro_possibles ) #NEWLINE# LOG . debug ( 'Matched distros %s' , [ m . name for m in matches ] ) #NEWLINE# return matches