Commit 9435d1d7 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix user_has_octave_forge_package

Packages are no longer autoloaded, so testing whether they are "Loaded" does
not work in all cases.

The function now ensures that the package is loaded.

This change was made for consistency with commit 7cbac0c9 in Dynare.
parent 8b956787
......@@ -46,13 +46,9 @@ if isoctave
fclose(fid);
if length(firstline) < 4097
if ~user_has_octave_forge_package('io')
try
pkg load io
catch
error(['The io package is required to read CSV files from Octave. ' ...
'It can be installed by running the following from the Octave ' ...
' command line: pkg install -forge io']);
end
error(['The io package is required to read CSV files from Octave. ' ...
'It can be installed by running the following from the Octave ' ...
' command line: pkg install -forge io']);
end
A = csv2cell(file);
[data, T, L] = parsecell(A);
......
......@@ -45,13 +45,9 @@ if nargin<3 || isempty(range)
end
if isoctave && ~user_has_octave_forge_package('io')
try
pkg load io
catch
error(['The io package is required to read CSV files from Octave. ' ...
'It can be installed by running the following from the Octave ' ...
' command line: pkg install -forge io']);
end
error(['The io package is required to read CSV files from Octave. ' ...
'It can be installed by running the following from the Octave ' ...
' command line: pkg install -forge io']);
end
% Check file extension.
......
......@@ -20,4 +20,11 @@ function [hasPackage] = user_has_octave_forge_package(package)
[desc,flag] = pkg('describe', package);
hasPackage = isequal(flag{1,1}, 'Loaded');
\ No newline at end of file
if isequal(flag{1,1}, 'Not installed')
hasPackage = 0;
else
if isequal(flag{1,1}, 'Not loaded')
pkg('load', package);
end
hasPackage = 1;
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment