Skip to content

Commit 0e98cd5

Browse files
committed
make read and load import the IO library
This implies, that all IO libraries shouldn't export their load and save functions, so they don't extend the FileIO functions anymore. This is a bigger change, but it seems to solve our `Lib A, Lib B can load/save the same format` problem nicely. It still works for libraries that overload, but we should ultimately make the change.
1 parent 27a0e50 commit 0e98cd5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/FileIO.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ function load(s::@compat(Union{AbstractString,IO}), args...; options...)
5555
last_exception = ErrorException("No library available to load $s")
5656
for library in libraries
5757
try
58-
check_loader(library)
59-
return load(q, args...; options...)
58+
Library = check_loader(library)
59+
return Library.load(q, args...; options...)
6060
catch e
6161
last_exception = e
6262
end
@@ -76,8 +76,8 @@ function save(s::@compat(Union{AbstractString,IO}), data...; options...)
7676
last_exception = ErrorException("No library available to save $s")
7777
for library in libraries
7878
try
79-
check_saver(library)
80-
return save(q, data...; options...)
79+
Library = check_saver(library)
80+
return Library.save(q, data...; options...)
8181
catch e
8282
last_exception = e #TODO, better and standardized exception propagation system
8383
end

src/loadsave.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ for (appl,fchk,fadd,dct) in ((:applicable_loaders, :check_loader, :add_loader, :
66
@eval begin
77
$appl{sym}(::Formatted{DataFormat{sym}}) = get($dct, sym, [:nothing])
88
function $fchk(pkg::Symbol)
9-
if !isdefined(Main, pkg)
10-
eval(Main, Expr(:using, pkg))
11-
end
9+
pkg == :nothing && return FileIO #nothing is the symbol for no load/save specific lib. see above
10+
!isdefined(Main, pkg) && eval(Main, Expr(:import, pkg))
11+
return Main.(pkg)
1212
end
1313
function $fadd{sym}(::Type{DataFormat{sym}}, pkg::Symbol)
1414
list = get($dct, sym, Symbol[])

0 commit comments

Comments
 (0)