matRad function to decrease computational expense Manipulates certain parameters in matRad pipeline so that it would be less computational expensive when it's being used in continuous integration builds. call matRad_unitTestTextManipulation(filename, string1, string2) matRad_unitTestTextManipulation(filename, string1, string2, path) input filename: file(s) to be manipulated, pass multiple files as cell array string1: string to be changed string2: string to be replaced path: (optional) path where the function is located. default is the parent directory '../' output - References - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright 2018 the matRad development team. This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function matRad_unitTestTextManipulation(filename, string1, string2, path) 0002 % matRad function to decrease computational expense 0003 % Manipulates certain parameters in matRad pipeline so that it would be 0004 % less computational expensive when it's being used in continuous 0005 % integration builds. 0006 % 0007 % call 0008 % matRad_unitTestTextManipulation(filename, string1, string2) 0009 % matRad_unitTestTextManipulation(filename, string1, string2, path) 0010 % 0011 % input 0012 % filename: file(s) to be manipulated, pass multiple files as cell array 0013 % string1: string to be changed 0014 % string2: string to be replaced 0015 % path: (optional) path where the function is located. default is the 0016 % parent directory '../' 0017 % 0018 % output 0019 % - 0020 % 0021 % References 0022 % - 0023 % 0024 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 % 0026 % Copyright 2018 the matRad development team. 0027 % 0028 % This file is part of the matRad project. It is subject to the license 0029 % terms in the LICENSE file found in the top-level directory of this 0030 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0031 % of the matRad project, including this file, may be copied, modified, 0032 % propagated, or distributed except according to the terms contained in the 0033 % LICENSE file. 0034 % 0035 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 0037 if nargin < 4 0038 path = ['.' filesep]; 0039 end 0040 0041 if ~iscell(filename) 0042 filename = {filename}; 0043 end 0044 0045 for fIx = 1:numel(filename) 0046 0047 currFilename = filename{fIx}; 0048 0049 fid=fopen([path currFilename]); 0050 fo=fopen('tempFile.m','w'); 0051 tline = fgetl(fid); 0052 0053 while ischar(tline) 0054 0055 if strfind(tline, string1) 0056 fprintf(fo, '%s\n', string2); 0057 else 0058 fprintf(fo, '%s\n', tline); 0059 end 0060 tline = fgetl(fid); 0061 end 0062 0063 0064 fclose(fid); 0065 fclose(fo); 0066 0067 0068 movefile('tempFile.m', [path currFilename], 'f'); 0069 end 0070 end 0071