Skip to content

Commit

Permalink
Mv {bicas.tools.batch-->irf.fs}.get_file_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPGJ committed Jun 3, 2024
1 parent 1a2be03 commit 44f1dfa
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
% NOTE: Function could be implemented recursively, but that is not needed since
% dir() handles that.
%
% PROPOSAL: Redefine as generic, outside of BICAS.
% PRO: Is used by solo.qli.batch.fmd.
%
% TODO-DEC: How handle non-existing files and directories?
% NOTE: Only existing directories can be translated into files. Ambiguity
% "only" exists for files.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%
% matlab.unittest automatic test code for bicas.tools.batch.get_file_paths().
% matlab.unittest automatic test code for irf.fs.get_file_paths().
%
%
% Author: Erik P G Johansson, IRF, Uppsala, Sweden
Expand Down Expand Up @@ -61,7 +61,7 @@ function test(fileDirPathsCa)
assert(iscolumn(fileDirPathsCa))

testCase.assertError(...
@() bicas.tools.batch.get_file_paths(fileDirPathsCa), ...
@() irf.fs.get_file_paths(fileDirPathsCa), ...
?MException)
end

Expand All @@ -82,11 +82,11 @@ function test_empty(testCase)
ExpFsoiArray1 = dir('~');
ExpFsoiArray1 = ExpFsoiArray1([], 1); % Column array.

emptyDir1 = bicas.tools.batch.get_file_paths___UTEST.create_directory(testDir, {'empty_dir1'});
emptyDir2 = bicas.tools.batch.get_file_paths___UTEST.create_directory(testDir, {'empty_dir2'});
emptyDir1 = irf.fs.get_file_paths___UTEST.create_directory(testDir, {'empty_dir1'});
emptyDir2 = irf.fs.get_file_paths___UTEST.create_directory(testDir, {'empty_dir2'});

function test(fileDirPathsCa)
[actFilePathsCa1, ActFsoiArray1] = bicas.tools.batch.get_file_paths___UTEST.test_call(...
[actFilePathsCa1, ActFsoiArray1] = irf.fs.get_file_paths___UTEST.test_call(...
testCase, fileDirPathsCa);

testCase.assertEqual(actFilePathsCa1, cell(0, 1))
Expand All @@ -108,11 +108,11 @@ function test_one_file(testCase)
testDir = testCase.testDir;

dir1 = fullfile(testDir, 'dir1');
emptyDir = bicas.tools.batch.get_file_paths___UTEST.create_directory( testDir, {'empty_dir'});
emptyDir = irf.fs.get_file_paths___UTEST.create_directory( testDir, {'empty_dir'});
file1 = irf.fs.create_empty_file({testDir, 'dir1', 'dir1', 'file1'});

function test(fileDirPathsCa)
[actFilePathsCa1, ActFsoiArray1] = bicas.tools.batch.get_file_paths___UTEST.test_call(...
[actFilePathsCa1, ActFsoiArray1] = irf.fs.get_file_paths___UTEST.test_call(...
testCase, fileDirPathsCa);

testCase.assertEqual(actFilePathsCa1, {file1})
Expand All @@ -130,8 +130,8 @@ function test(fileDirPathsCa)
function test_mixed_complex(testCase)
testDir = testCase.testDir;

dirWithEmptySubdir = bicas.tools.batch.get_file_paths___UTEST.create_directory( testDir, {'dir_with_empty_subdir'});
[~] = bicas.tools.batch.get_file_paths___UTEST.create_directory( testDir, {'dir_with_empty_subdir', 'dir1'});
dirWithEmptySubdir = irf.fs.get_file_paths___UTEST.create_directory( testDir, {'dir_with_empty_subdir'});
[~] = irf.fs.get_file_paths___UTEST.create_directory( testDir, {'dir_with_empty_subdir', 'dir1'});

dir1 = fullfile( testDir, 'dir1');
file11 = irf.fs.create_empty_file({testDir, 'dir1', 'file1'});
Expand All @@ -141,7 +141,7 @@ function test_mixed_complex(testCase)
file21 = irf.fs.create_empty_file({testDir, 'dir2', 'file1'});
file211 = irf.fs.create_empty_file({testDir, 'dir2', 'dir1', 'file11'});

[actFilePathsCa1, ~] = bicas.tools.batch.get_file_paths___UTEST.test_call(...
[actFilePathsCa1, ~] = irf.fs.get_file_paths___UTEST.test_call(...
testCase, {dirWithEmptySubdir; dir1; file21; file211} ...
);

Expand Down Expand Up @@ -169,7 +169,7 @@ function test_mixed_complex(testCase)
function [actFilePathsCa1, ActFsoiArray1] = test_call(testCase, fileDirPathsCa)
expFieldNamesCa = fieldnames(dir('~'));

[actFilePathsCa1, ActFsoiArray1] = bicas.tools.batch.get_file_paths(fileDirPathsCa);
[actFilePathsCa1, ActFsoiArray1] = irf.fs.get_file_paths(fileDirPathsCa);

% Check existence of struct fields.
testCase.assertEqual(...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

function [pathsCa, fmdDtArray] = get_file_paths_FMDs(obj, dirsCa)

[pathsCa, FsoiArray] = bicas.tools.batch.get_file_paths(dirsCa);
[pathsCa, FsoiArray] = irf.fs.get_file_paths(dirsCa);
if ~isempty(FsoiArray)
fmdDtArray = datetime([FsoiArray.datenum], 'ConvertFrom', 'datenum');
else
Expand Down
3 changes: 0 additions & 3 deletions mission/solar_orbiter/+solo/+qli/+batch/fmd.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
% Author: Erik P G Johansson, IRF, Uppsala, Sweden
%
classdef fmd
% NOTE: Uses BICAS code: bicas.tools.batch.get_file_paths().
% PROPOSAL: Refactor it to a generic function.
%
% PROPOSAL: Argument for specifying some kind of upper limit to the number of
% days returned.
% PROPOSAL: Specify interval of dates. -- IMPLEMENTED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
% Get reference DSMDs
%=====================
if ~isempty(referenceDir)
[filePathsCa, ~] = bicas.tools.batch.get_file_paths({referenceDir});
[filePathsCa, ~] = irf.fs.get_file_paths({referenceDir});
[RefDsmdArray, ~] = solo.adm.paths_to_DSMD_array(filePathsCa);
else
RefDsmdArray = solo.adm.DSMD.empty(0, 1);
Expand Down Expand Up @@ -131,7 +131,7 @@
else
referenceDirCa = {referenceDir};
end
[filePathsCa, ~] = bicas.tools.batch.get_file_paths(inputPathsCa);
[filePathsCa, ~] = irf.fs.get_file_paths(inputPathsCa);
[InputDsmdArray, ~] = solo.adm.paths_to_DSMD_array(filePathsCa);
if DEBUG_ENABLED
log_DSMD_array('Input directories (only recognized datasets)', InputDsmdArray)
Expand Down

0 comments on commit 44f1dfa

Please sign in to comment.