Skip to content

Commit 50d1274

Browse files
committed
Drop julia-0.3 support and eliminate Docile requirement
1 parent 765ec49 commit 50d1274

File tree

6 files changed

+56
-68
lines changed

6 files changed

+56
-68
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ os:
33
- linux
44
- osx
55
julia:
6-
- 0.3
76
- 0.4
87
- nightly
98
notifications:

REQUIRE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
julia 0.3
1+
julia 0.4
22
Compat 0.7.19
3-
# The rest are needed only on julia 0.3
4-
Docile

src/FileIO.jl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ module FileIO
44
using Compat
55
import Compat.String
66

7-
if VERSION < v"0.4.0-dev"
8-
using Docile
9-
immutable Pair{A,B}
10-
first::A
11-
second::B
12-
end
13-
Base.first(p::Pair) = p.first
14-
Base.last(p::Pair) = p.second
15-
end
16-
177
export DataFormat,
188
File,
199
Formatted,
@@ -44,7 +34,7 @@ include("error_handling.jl")
4434
include("loadsave.jl")
4535
include("registry.jl")
4636

47-
@doc """
37+
"""
4838
`FileIO` API (brief summary, see individual functions for more detail):
4939
5040
- `format"PNG"`: specifies a particular defined format
@@ -66,6 +56,7 @@ include("registry.jl")
6656
- `add_format(fmt, magic, extension)`: register a new format
6757
- `add_loader(fmt, :Package)`: indicate that `Package` supports loading files of type `fmt`
6858
- `add_saver(fmt, :Package)`: indicate that `Package` supports saving files of type `fmt`
69-
""" -> FileIO
59+
"""
60+
FileIO
7061

7162
end

src/error_handling.jl

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
@doc """
1+
"""
22
`LoaderError` should be thrown when loader library code fails, and other libraries should
33
be given the chance to recover from the error. Reports the library name and an error message:
44
LoaderError("ImageMagick", "Foo not available")
5-
""" ->
5+
"""
66
immutable LoaderError <: Exception
77
library::Compat.UTF8String
88
msg::Compat.UTF8String
99
end
1010
Base.showerror(io::IO, e::LoaderError) = println(io, e.library, " load error: ",
1111
msg, "\n Will try next loader.")
1212

13-
@doc """
13+
"""
1414
`WriterError` should be thrown when writer library code fails, and other libraries should
1515
be given the chance to recover from the error. Reports the library name and an error message:
1616
WriterError("ImageMagick", "Foo not available")
17-
""" ->
17+
"""
1818
immutable WriterError <: Exception
1919
library::Compat.UTF8String
2020
msg::Compat.UTF8String
@@ -24,27 +24,27 @@ Base.showerror(io::IO, e::WriterError) = println(
2424
msg, "\n Will try next writer."
2525
)
2626

27-
@doc """
27+
"""
2828
`NotInstalledError` should be thrown when a library is currently not installed.
29-
""" ->
29+
"""
3030
immutable NotInstalledError <: Exception
3131
library::Symbol
3232
message::Compat.UTF8String
3333
end
3434
Base.showerror(io::IO, e::NotInstalledError) = println(io, e.library, " is not installed.")
3535

36-
@doc """
36+
"""
3737
`UnknownFormat` gets thrown when FileIO can't recognize the format of a file.
38-
""" ->
38+
"""
3939
immutable UnknownFormat{T <: Formatted} <: Exception
4040
format::T
4141
end
4242
Base.showerror(io::IO, e::UnknownFormat) = println(io, e.format, " couldn't be recognized by FileIO.")
4343

4444

45-
@doc """
45+
"""
4646
Handles error as soon as they get thrown while doing IO
47-
""" ->
47+
"""
4848
function handle_current_error(e, library, islast::Bool)
4949
bt = catch_backtrace()
5050
bts = sprint(io->Base.show_backtrace(io, bt))
@@ -53,9 +53,9 @@ function handle_current_error(e, library, islast::Bool)
5353
end
5454
handle_current_error(e::NotInstalledError) = warn(string("lib ", e.library, " not installed, trying next library"))
5555

56-
@doc """
56+
"""
5757
Handles a list of thrown errors after no IO library was found working
58-
""" ->
58+
"""
5959
function handle_error(exceptions::Vector)
6060
for exception in exceptions
6161
continue_ = handle_error(exception...)
@@ -77,12 +77,10 @@ function handle_error(e::NotInstalledError, q)
7777
return false # don't continue
7878
elseif input == "n"
7979
info(string("Not installing ", e.library))
80-
return true # User does not install, continue going through errors.
80+
return true # User does not install, continue going through errors.
8181
else
8282
println("$input is not a valid choice. Try typing y or n")
8383
end
8484
end
85-
true # User does not install, continue going through errors.
85+
true # User does not install, continue going through errors.
8686
end
87-
88-

src/loadsave.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,29 @@ for (applicable_, add_, dict_) in (
2828
end
2929

3030

31-
@doc "`add_loader(fmt, :Package)` triggers `using Package` before loading format `fmt`" -> add_loader
32-
@doc "`add_saver(fmt, :Package)` triggers `using Package` before saving format `fmt`" -> add_saver
31+
"`add_loader(fmt, :Package)` triggers `using Package` before loading format `fmt`"
32+
add_loader
33+
"`add_saver(fmt, :Package)` triggers `using Package` before saving format `fmt`"
34+
add_saver
3335

3436

35-
@doc """
37+
"""
3638
- `load(filename)` loads the contents of a formatted file, trying to infer
3739
the format from `filename` and/or magic bytes in the file.
3840
- `load(strm)` loads from an `IOStream` or similar object. In this case,
3941
the magic bytes are essential.
4042
- `load(File(format"PNG",filename))` specifies the format directly, and bypasses inference.
4143
- `load(f; options...)` passes keyword arguments on to the loader.
42-
""" ->
44+
"""
4345
load(s::@compat(Union{AbstractString,IO}), args...; options...) =
4446
load(query(s), args...; options...)
4547

46-
@doc """
48+
"""
4749
- `save(filename, data...)` saves the contents of a formatted file,
4850
trying to infer the format from `filename`.
4951
- `save(Stream(format"PNG",io), data...)` specifies the format directly, and bypasses inference.
5052
- `save(f, data...; options...)` passes keyword arguments on to the saver.
51-
""" ->
53+
"""
5254
save(s::@compat(Union{AbstractString,IO}), data...; options...) =
5355
save(query(s), data...; options...)
5456

src/query.jl

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ function add_loadsave(format, predicates)
3030
end
3131
end
3232

33-
@doc """
33+
"""
3434
`DataFormat{sym}()` indicates a known binary or text format of kind `sym`,
3535
where `sym` is always a symbol. For example, a .csv file might have
3636
`DataFormat{:CSV}()`.
3737
3838
An easy way to write `DataFormat{:CSV}` is `format"CSV"`.
39-
""" ->
39+
"""
4040
immutable DataFormat{sym} end
4141

4242
macro format_str(s)
@@ -45,8 +45,8 @@ end
4545

4646
const unknown_df = DataFormat{:UNKNOWN}
4747

48-
@doc """
49-
`unknown(f)` returns true if the format of `f` is unknown.""" ->
48+
"""
49+
`unknown(f)` returns true if the format of `f` is unknown."""
5050
unknown(::Type{format"UNKNOWN"}) = true
5151
unknown{sym}(::Type{DataFormat{sym}}) = false
5252

@@ -64,7 +64,7 @@ function add_format(fmt, magic, extension, load_save_libraries...)
6464
fmt
6565
end
6666

67-
@doc """
67+
"""
6868
`add_format(fmt, magic, extention)` registers a new `DataFormat`.
6969
For example:
7070
@@ -73,7 +73,7 @@ For example:
7373
add_format(format"NRRD", "NRRD", [".nrrd",".nhdr"])
7474
7575
Note that extensions, magic numbers, and format-identifiers are case-sensitive.
76-
""" ->
76+
"""
7777
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,String}), extension)
7878
haskey(sym2info, sym) && error("format ", fmt, " is already registered")
7979
m = canonicalize_magic(magic)
@@ -113,9 +113,9 @@ function add_format{sym}(fmt::Type{DataFormat{sym}}, magic, extension)
113113
fmt
114114
end
115115

116-
@doc """
116+
"""
117117
`del_format(fmt::DataFormat)` deletes `fmt` from the format registry.
118-
""" ->
118+
"""
119119
function del_format{sym}(fmt::Type{DataFormat{sym}})
120120
magic, extension = sym2info[sym]
121121
del_magic(magic, sym)
@@ -148,9 +148,9 @@ function del_magic{N}(magic::NTuple{N, UInt8}, sym)
148148
nothing
149149
end
150150

151-
@doc """
151+
"""
152152
`info(fmt)` returns the magic bytes/extension information for
153-
`DataFormat` `fmt`.""" ->
153+
`DataFormat` `fmt`."""
154154
Base.info{sym}(::Type{DataFormat{sym}}) = sym2info[sym]
155155

156156

@@ -209,32 +209,32 @@ end
209209

210210
abstract Formatted{F<:DataFormat} # A specific file or stream
211211

212-
@doc """
212+
"""
213213
`File(fmt, filename)` indicates that `filename` is a file of known
214214
DataFormat `fmt`. For example, `File{fmtpng}(filename)` would indicate a PNG
215-
file.""" ->
215+
file."""
216216
immutable File{F<:DataFormat} <: Formatted{F}
217217
filename::Compat.UTF8String
218218
end
219219
File{sym}(fmt::Type{DataFormat{sym}}, filename) = File{fmt}(filename)
220220

221-
@doc """
221+
"""
222222
`filename(file)` returns the filename associated with `File` `file`.
223-
""" ->
223+
"""
224224
filename(f::File) = f.filename
225225

226-
@doc """
226+
"""
227227
`file_extension(file)` returns the file extension associated with `File` `file`.
228-
""" ->
228+
"""
229229
file_extension(f::File) = splitext(filename(f))[2]
230230

231231

232232

233-
@doc """
233+
"""
234234
`Stream(fmt, io, [filename])` indicates that the stream `io` is
235235
written in known `Format`. For example, `Stream{PNG}(io)` would
236236
indicate PNG format. If known, the optional `filename` argument can
237-
be used to improve error messages, etc.""" ->
237+
be used to improve error messages, etc."""
238238
immutable Stream{F<:DataFormat,IOtype<:IO} <: Formatted{F}
239239
io::IOtype
240240
filename::Nullable{Compat.UTF8String}
@@ -245,17 +245,17 @@ Stream{F<:DataFormat}(::Type{F}, io::IO, filename::AbstractString) = Stream{F,ty
245245
Stream{F<:DataFormat}(::Type{F}, io::IO, filename) = Stream{F,typeof(io)}(io,filename)
246246
Stream{F}(file::File{F}, io::IO) = Stream{F,typeof(io)}(io,filename(file))
247247

248-
@doc "`stream(s)` returns the stream associated with `Stream` `s`" ->
248+
"`stream(s)` returns the stream associated with `Stream` `s`"
249249
stream(s::Stream) = s.io
250250

251-
@doc """
251+
"""
252252
`filename(stream)` returns a nullable-string of the filename
253-
associated with `Stream` `stream`.""" ->
253+
associated with `Stream` `stream`."""
254254
filename(s::Stream) = s.filename
255255

256-
@doc """
256+
"""
257257
`file_extension(file)` returns a nullable-string for the file extension associated with `Stream` `stream`.
258-
""" ->
258+
"""
259259
function file_extension(f::Stream)
260260
isnull(filename(f)) && return filename(f)
261261
splitext(get(filename(f)))[2]
@@ -301,13 +301,13 @@ Base.readbytes(s::Stream, nb) = read(stream(s), nb)
301301
Base.isreadonly(s::Stream) = isreadonly(stream(s))
302302
Base.isopen(s::Stream) = isopen(stream(s))
303303

304-
@doc "`magic(fmt)` returns the magic bytes of format `fmt`" ->
304+
"`magic(fmt)` returns the magic bytes of format `fmt`"
305305
magic{F<:DataFormat}(fmt::Type{F}) = UInt8[info(fmt)[1]...]
306306

307-
@doc """
307+
"""
308308
`skipmagic(s)` sets the position of `Stream` `s` to be just after the magic bytes.
309309
For a plain IO object, you can use `skipmagic(io, fmt)`.
310-
""" ->
310+
"""
311311
skipmagic{F}(s::Stream{F}) = (skipmagic(stream(s), F); s)
312312
function skipmagic{sym}(io, fmt::Type{DataFormat{sym}})
313313
magic, _ = sym2info[sym]
@@ -345,9 +345,9 @@ end
345345
unknown{F}(::File{F}) = unknown(F)
346346
unknown{F}(::Stream{F}) = unknown(F)
347347

348-
@doc """
348+
"""
349349
`query(filename)` returns a `File` object with information about the
350-
format inferred from the file's extension and/or magic bytes.""" ->
350+
format inferred from the file's extension and/or magic bytes."""
351351
function query(filename::AbstractString)
352352
_, ext = splitext(filename)
353353
if haskey(ext2sym, ext)
@@ -381,9 +381,9 @@ hasfunction(v::Vector) = any(hasfunction, v)
381381
hasfunction(s::Any) = true #has function
382382
hasfunction(s::Tuple) = false #has magic
383383

384-
@doc """
384+
"""
385385
`query(io, [filename])` returns a `Stream` object with information about the
386-
format inferred from the magic bytes.""" ->
386+
format inferred from the magic bytes."""
387387
query(io::IO, filename) = query(io, Nullable(Compat.UTF8String(filename)))
388388

389389
function query(io::IO, filename::Nullable{Compat.UTF8String}=Nullable{Compat.UTF8String}())

0 commit comments

Comments
 (0)