Skip to content
Snippets Groups Projects
Commit 2c6e2a81 authored by M. Hock's avatar M. Hock
Browse files

adjusted scriptpath handling in publish, it will always be handled as cell...

adjusted scriptpath handling in publish, it will always be handled as cell array, if its a string or char array it will be packed into a 1 cell array. CopyUserFCN and CopyFiles already handle cell arrays of filepaths.
TODO: adjust Readme and documentation
parent d95edc5a
No related tags found
No related merge requests found
Pipeline #655816 failed
......@@ -8,10 +8,10 @@ function Publish(DataPaths,scriptPath, figure, options)
% the simple call of scriptPath = [mfilename('fullpath'),'.m']
%
% Options:
% Location sets the storage location. 'local' sets the storage location
% 'Location' sets the storage location. 'local' sets the storage location
% to the current folder (an export folder will be created), 'manual' opens
% an explorer window, where you can choose the folder. If you define a export
% path in the config file, this will used per default (exportPath).
% an user interface win you can choose the folder. If you define an export
% path in the config file, it will be used as default (exportPath).
% remote path, that is defined in the config file.
% Two Methods are implemented 'individual' stores the data for
% each plot while 'centralized' uses a data folder and uses reference links
......@@ -41,10 +41,7 @@ arguments
end
%% argument validation
% strings will cause problems, therefore chars are used
if isstring(scriptPath)
scriptPath = char(scriptPath);
end
%catch multiple figures in fig
if numel(figure) > 1
......@@ -55,22 +52,42 @@ if numel(figure) > 1
warning(msg);
end
% find scriptpath
if ~isfile(scriptPath)
scriptPath= which(scriptPath);
if ~isfile(scriptPath)
msg = ['Script path: ',scriptPath, ' not found on matlab path', newline, ...
'- check spelling or us a path'];
error(msg);
end
% convert single path to cell and handle cell array
if isstring(scriptPath) && ischar(scriptPath)
scriptPath={scriptPath};
end
% catch missing .m extension
[~,~, scriptExt] = fileparts(scriptPath);
if isempty(scriptExt)
scriptPath = [scriptPath,'.m'];
% if it was string before, its a cell now, otherwise continue with elements
if ~iscellstr(scriptPath)
msg = ['Could not recognize script path as character array'];
error(msg)
end
for i=1:length(scriptPath)
% strings will cause problems, therefore chars are used
if isstring(scriptPath{i})
scriptPath{i}= char(scriptPath{i});
end
% find scriptpath
if ~isfile(scriptPath{i})
scriptPath{i}= which(scriptPath{i});
if ~isfile(scriptPath{i})
msg = ['Script path: ',scriptPath{i}, ' not found on matlab path', newline, ...
'- check spelling or us a path'];
error(msg);
end
end
% catch missing .m extension
[~,~, scriptExt] = fileparts(scriptPath{i});
if isempty(scriptExt)
scriptPath{i} = [scriptPath{i},'.m'];
end
end
%get ID from Figure
ID = figure.Tag;
......@@ -109,7 +126,7 @@ switch options.Location
storPath = options.ParentFolder;
else
% use the script path as export path
scriptLocation = fileparts(scriptPath);
scriptLocation = fileparts(scriptPath{1});
storPath = fullfile(scriptLocation,options.ParentFolder);
end
case 'exportPath'
......@@ -155,7 +172,7 @@ disp(['publishing of ', ID, ' started']);
%% Create a copy of the script and user functions(optional)
% script
[~, status, msg] = PlotID.createFileCopy({scriptPath},folderName,storPath,ID, 'script');
[~, status, msg] = PlotID.createFileCopy(scriptPath,folderName,storPath,ID, 'script');
dlgObj.scriptPublished =status;
dlgObj.userMSG(msg);
......
......@@ -14,10 +14,10 @@ Feel free to give feedback and feature requests or to take part in the developme
**First use:**
1. Put your PlotID folder in you [userpath](https://uk.mathworks.com/help/matlab/ref/userpath.html) on Windows this is
`C:\Users\USERNAME\Documents\MATLAB`. \
When using a diffrent folder, make sure the folder is on your [search path](https://uk.mathworks.com/help/matlab/matlab_env/add-remove-or-reorder-folders-on-the-search-path.html).
When using a different folder, make sure the folder is on your [search path](https://uk.mathworks.com/help/matlab/matlab_env/add-remove-or-reorder-folders-on-the-search-path.html).
2. Run `Initialisation.m` and follow the command line instructions.\
The **ProjectID** is your custom project number, it well be the prefix of the ID created by `PlotID` (e.g. JL-001). Save your config file.
The **ProjectID** is your custom project number, it will become the prefix of the ID created by `PlotID` (e.g. JL-001). Save your config file.
**Intended use:**\
`PlotID` works in two Steps:
......@@ -168,6 +168,6 @@ you need to provide the name of your custom config file to tagplot as well as to
The authors would like to thank the Federal Government and the Heads of Government of the Länder, as well as the Joint Science Conference (GWK), for their funding and support within the framework of the NFDI4Ing consortium. Funded by the German Research Foundation (DFG) - project number 442146713.
# Known Issues
**Closed figure will cause error** Please do not cloase the figure, MATLAB deletes the object if you do so.
**Closed figure will cause error** Please do not close the figure, MATLAB deletes the object if you do so.
**Centralized Method does not work on Linux systems**
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment