From 0349d6774bb7090ed4942a48041ec913655e8f24 Mon Sep 17 00:00:00 2001 From: "Nikolaas N. Oosterhof" Date: Wed, 27 Jul 2016 14:23:47 +0200 Subject: [PATCH] RF: always set exclude pattern --- MOcov/@MOcovMFileCollection/get_coverage_json.m | 4 +-- MOcov/mocov_find_files.m | 37 +++++++++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/MOcov/@MOcovMFileCollection/get_coverage_json.m b/MOcov/@MOcovMFileCollection/get_coverage_json.m index 600ca58..87f2813 100644 --- a/MOcov/@MOcovMFileCollection/get_coverage_json.m +++ b/MOcov/@MOcovMFileCollection/get_coverage_json.m @@ -28,7 +28,7 @@ 'UniformOutput',false); source_files_json=strjoin(source_files_json_cell,','); - misc_data=get_misc_data(params); + misc_data=get_misc_data(service); json=sprintf(['{ \n',... '"service_job_id": "%s",\n',... @@ -67,7 +67,7 @@ misc_data_cell=cell(0); if isfield(params,'parallel') % attempt to support parallel - misc_data_cell{end+1}=sprintf(',"parallel": %s\n',... + misc_data_cell{end+1}=sprintf('"parallel": %s,\n',... lower(params.parallel)); end misc_data=sprintf('%s',misc_data_cell{:}); diff --git a/MOcov/mocov_find_files.m b/MOcov/mocov_find_files.m index f6c2e24..549dae3 100644 --- a/MOcov/mocov_find_files.m +++ b/MOcov/mocov_find_files.m @@ -50,23 +50,35 @@ regexptranslate('wildcard',file_pat) ... '$']; % end of the string - exclude_re=''; - for k=1:numel(exclude_pat) - if ~isempty(exclude_re) - exclude_re=[exclude_re '|']; - end - exclude_re=[exclude_re ... - '^' ... % start of the string - regexptranslate('wildcard',exclude_pat{k}) ... - '$']; % end of the string - end + exclude_re=get_exclude_re(exclude_pat); if ~isempty(monitor) msg=sprintf('Finding files matching %s from %s',file_pat,root_dir); notify(monitor, msg); end - res=find_files_recursively(root_dir,file_re,monitor); + res=find_files_recursively(root_dir,file_re,monitor,exclude_re); + +function re=get_exclude_re(exclude_pat) + n=numel(exclude_pat); + if n==0 + re=''; + return; + end + + excl_re_cell=cell(n,1); + for k=1:n + re_k=['^' ... % start of the string + regexptranslate('wildcard',exclude_pat{k}) ... + '$']; % end of the string + excl_re_cell{k}=re_k; + end + + joined=sprintf('|%s',excl_re_cell{:}); + re=joined(2:end); + + + function res=find_files_recursively(root_dir,file_re,monitor,exclude_re) if isempty(root_dir) @@ -91,7 +103,8 @@ if ~isempty(regexp(fn,exclude_re,'once')); continue; elseif isdir(path_fn) - res=find_files_recursively(path_fn,file_re,monitor,exclude_re); + res=find_files_recursively(path_fn,file_re,... + monitor,exclude_re); elseif ~isempty(regexp(fn,file_re,'once')); res={path_fn}; if ~isempty(monitor)