#NEWLINE# def get_resources_dests( resources_root , rules ) : #NEWLINE# #INDENT# 'Find destinations for resources files' #NEWLINE# def get_rel_path( base , path ) : #NEWLINE# #INDENT# base = base . replace ( os . path . sep , '/' ) #NEWLINE# path = path . replace ( os . path . sep , '/' ) #NEWLINE# assert path . startswith ( base ) #NEWLINE# return path [ len ( base ) : ] . lstrip ( '/' ) #NEWLINE# #UNINDENT# destinations = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( base , suffix , dest ) in rules : #NEWLINE# #INDENT# prefix = os . path . join ( resources_root , base ) #NEWLINE# for abs_base in iglob ( prefix ) : #NEWLINE# #INDENT# abs_glob = os . path . join ( abs_base , suffix ) #NEWLINE# for abs_path in iglob ( abs_glob ) : #NEWLINE# #INDENT# resource_file = get_rel_path ( resources_root , abs_path ) #NEWLINE# if ( dest is None ) : #NEWLINE# #INDENT# destinations . pop ( resource_file , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# rel_path = get_rel_path ( abs_base , abs_path ) #NEWLINE# rel_dest = dest . replace ( os . path . sep , '/' ) . rstrip ( '/' ) #NEWLINE# destinations [ resource_file ] = ( ( rel_dest + '/' ) + rel_path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return destinations