From 774ecef22862b9dba5cbab5ee8e44beffb6c06b9 Mon Sep 17 00:00:00 2001 From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de> Date: Wed, 24 Nov 2021 12:32:15 +0100 Subject: [PATCH] Use Export Path from config file --- +PlotID/@config/config.m | 6 +++++- +PlotID/@config/wizard.m | 2 +- +PlotID/Publish.m | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/+PlotID/@config/config.m b/+PlotID/@config/config.m index c6d2bae..34a3df9 100644 --- a/+PlotID/@config/config.m +++ b/+PlotID/@config/config.m @@ -12,6 +12,7 @@ classdef config < handle properties (SetAccess = protected) configData configFileName + exportPath = '' end methods @@ -23,7 +24,10 @@ classdef config < handle txt = fileread(obj.configFileName); obj.configData = jsondecode(txt); assert(checkConfig(obj)); - + if isfield(obj.configData,'ExportPath') + obj.exportPath = obj.configData.ExportPath; + obj.configData.options.Location = 'exportPath'; + end catch msg = ['no valid config File with the filename ',... obj.configFileName, ' found.' newline,... diff --git a/+PlotID/@config/wizard.m b/+PlotID/@config/wizard.m index 47f3d8a..dfca286 100644 --- a/+PlotID/@config/wizard.m +++ b/+PlotID/@config/wizard.m @@ -15,7 +15,7 @@ switch mode m = input('Do you want to add an export path? Y/N [Y]:','s'); if ismember(m,{'Y','y'}) - config.ServerPath = uigetdir(); + config.ExportPath = uigetdir(); end otherwise error('wizard mode undefined in CLASS config'); diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index dc58a47..b94c5cf 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -74,9 +74,13 @@ end %% read config file % there is only one config Object (handleClass) configObj = PlotID.config(options.ConfigFileName); +% add user options if isfield(configObj.configData, 'options') - % is working but prune to user errors - options = configObj.configData.options; + fldnames = fieldnames(configObj.configData.options); + for ii=1:numel(fldnames) + field = fldnames{ii}; + options.(field) = configObj.configData.options.(field); + end end % Error and MSG handeling @@ -92,14 +96,22 @@ switch options.Location % use the script path as export path scriptLocation = fileparts(scriptPath); storPath = fullfile(scriptLocation,options.ParentFolder); + end + case 'exportPath' %legacy + if isfolder(configObj.exportPath) + storPath = configObj.exportPath; + else + msg = ['Your Export folder ', storPath, newline,... + 'does not exist - publishing not possible']; + dlgObj.error(msg); end - case 'server' %from config File + case 'server' %legacy if dlgObj.configError msg = ['Error while reading the config file' newline,... ' publishing on server not possible']; dlgObj.error(msg); end - storPath = config.ServerPath; + storPath = configObj.configData.ServerPath; case 'manual' %UI storPath = uigetdir(); case 'CI-Test' @@ -258,7 +270,7 @@ if dlgObj.success || options.ForcePublish end if status - disp(['publishing of ', ID , ' done']); %always displayed onsucess + disp(['publishing of ', ID , ' to ', newPath, ' done']); %always displayed onsucess else % publish was not sucessfull! %replace with error from userDLG Class dlgObj.error(['publishing of ', ID , ' failed']) -- GitLab