Skip to content
Snippets Groups Projects
Commit 6cd717fd authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Merge branch '96-analyse-der-verwendeten-funktionen-matlab-packages' into 'development'

Implements #96

See merge request !55
parents 43a23c29 314302a3
Branches
No related tags found
2 merge requests!62Introduce changes for V1.0 RC 1,!55Implements #96
Pipeline #652635 passed
......@@ -161,13 +161,7 @@ dlgObj.userMSG(msg);
% user functions
if options.CopyUserFCN
[fList,pList] = matlab.codetools.requiredFilesAndProducts(scriptPath);
fList = fList(~ismember(fList,scriptPath)); % rmv script from list
fList = fList(~contains(fList,'config.json')); % rmv config.json from list
fList = PlotID.removePltIdFiles(fList); % Do not copy files that are part of PlotID
if ~isempty(fList)
PlotID.createFileCopy(fList,folderName,storPath,ID,'userFcn');
end
toolboxList = PlotID.copyUserFCN(scriptPath, folderName, storPath, ID);
end
%% Research data handling
......@@ -239,7 +233,7 @@ meta.ProjectID = ID;
meta.CreationDate = datestr(now);
meta.MatlabVersion = version;
if options.CopyUserFCN
meta.ToolboxVersions = pList;
meta.ToolboxVersions = toolboxList;
end
% write meta
metaPath = fullfile(storPath,folderName,'plotID_data.json');
......
function pList = copyUserFCN(scriptPath, folderName, storPath, ID)
%COPYUSERFCN copies all user functions, classes and toolboxes that are used
%by the base script (scriptpath).
% folderName, storPath and ID are required for createfilecopy
[fList,pList] = matlab.codetools.requiredFilesAndProducts(scriptPath);
fList = fList(~ismember(fList,scriptPath)); % rmv plot script itself from list
fList = fList(~contains(fList,'config.json')); % rmv config.json from list
fList = removePltIdFiles(fList); % Do not copy files that are part of PlotID
% copy Classes and Toolboxes as a whole
copyTBorClass(fList,'+', folderName, storPath, ID); % Toolboxes
copyTBorClass(fList,'@', folderName, storPath, ID); % Classes
%remove class and toolbox files from flist
fList = fList(~contains(fList,{'@','+'}));
% copy User FCN
if ~isempty(fList)
PlotID.createFileCopy(fList,folderName,storPath,ID,'userFcn');
end
end
function [fListClean] = removePltIdFiles(fList)
%removePltIdFiles removes functions that are part of PlotID out of flist
% Detailed explanation goes here
[~,names,ext] = fileparts(fList);
names = strcat(names, ext); % add ext for comparison
% Get a list of all .m files that are part of Plot id
packageContent = what('PlotID');
% packageContent.classes has no extensions
PltID_classlist = packageContent.classes;
% Class Methods need to be listed in an additional function
Class_flist = cell(1,numel(packageContent.classes)); %preallocate
for i=1:numel(packageContent.classes)
temp = what(['PlotID',filesep,'@',PltID_classlist{i}]);
Class_flist{i} = temp.m;
end
Class_flist = vertcat(Class_flist{:});
% all plotID .m files:
PltID_flist = [packageContent.m; Class_flist];
% Comparison and filter
fListClean = fList(~ismember(names,PltID_flist));
end
function [status, msg] = copyTBorClass(fList,leadChar, folderName, storPath, ID)
%copyTBorClass copies the Toolboxes or Classes that are part of flist
% lead char must be either '@' for Classes or '+' for Toolboxes
if any(contains(fList,leadChar))
list = fList(contains(fList, leadChar));
names = extractBetween(list,leadChar,filesep);
paths = extractBefore(list,strcat(leadChar,names));
fullPaths = strcat(paths,strcat(leadChar,names));
fullPaths = unique(fullPaths);
[~, status, msg] =PlotID.createFileCopy(fullPaths,...
folderName,storPath,ID,'class');
end %if
end
\ No newline at end of file
......@@ -29,6 +29,8 @@ end
case 'userFcn'
%keep original name
newfile = sprintf([name,ext]);
case {'class','toolbox'}
newfile = name; % copy whole folder
otherwise
error([type,' is not a valid type for createFileCopy'])
end %switch
......
function [fListClean] = removePltIdFiles(fList)
%removePltIdFiles removes functions that are part of PlotID out of flist
% Detailed explanation goes here
[~,names,ext] = fileparts(fList);
names = strcat(names, ext); % add ext for comparison
% Get a list of all .m files that are part of Plot id
packageContent = what('PlotID');
% packageContent.classes has no extensions
PltID_classlist = packageContent.classes;
% Class Methods need to be listed in an additional function
Class_flist = cell(1,numel(packageContent.classes)); %preallocate
for i=1:numel(packageContent.classes)
temp = what(['PlotID',filesep,'@',PltID_classlist{i}]);
Class_flist{i} = temp.m;
end
Class_flist = vertcat(Class_flist{:});
% all plotID .m files:
PltID_flist = [packageContent.m; Class_flist];
% Comparison and filter
fListClean = fList(~ismember(names,PltID_flist));
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment