#NEWLINE# def prepend_directory_to_variable( self , directory , variable ) : #NEWLINE# #INDENT# ' Append a new directory to an environment variable\n        containing a list of paths (most of the time PATH, but\n        can be LIBDIR, for instance when using cl.exe)\n\n        * The path will always be sanitize first\n            (absolute, native path)\n\n        * No directory will be added twice\n\n        * The variable will be put in upper case on the dictionary\n          on windows.\n\n        ' #NEWLINE# pathsep = os . path . pathsep #NEWLINE# if sys . platform . startswith ( 'win' ) : #NEWLINE# #INDENT# variable = variable . upper ( ) #NEWLINE# #UNINDENT# directory = qisys . sh . to_native_path ( directory ) #NEWLINE# old_value = self . _build_env . get ( variable , '' ) #NEWLINE# if old_value . endswith ( pathsep ) : #NEWLINE# #INDENT# old_value = old_value [ : ( - 1 ) ] #NEWLINE# #UNINDENT# splitted_paths = old_value . split ( self ) #NEWLINE# if ( directory in splitted_paths ) : #NEWLINE# #INDENT# splitted_paths . remove ( directory ) #NEWLINE# #UNINDENT# splitted_paths . insert ( 0 , directory ) #NEWLINE# self . _build_env [ variable ] = pathsep . join ( splitted_paths )