Skip to content

Commit 1373ebd

Browse files
authored
Merge pull request #66 from JuliaIO/sd/depwarn_warn
remove depwarns and test warnings
2 parents 201cc08 + 50d1274 commit 1373ebd

File tree

9 files changed

+84
-86
lines changed

9 files changed

+84
-86
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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
julia 0.3
2-
Compat 0.7.15
3-
# The rest are needed only on julia 0.3
4-
Docile
1+
julia 0.4
2+
Compat 0.7.19

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: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ immutable SAVE end
1111
split_predicates(list) = filter(x-> x <: OS, list), filter(x-> !(x <: OS), list)
1212
applies_to_os(os::Vector) = isempty(os) || any(applies_to_os, os)
1313
applies_to_os{O <: OS}(os::Type{O}) = false
14-
@unix_only applies_to_os{U <: Unix}(os::Type{U}) = true
15-
@windows_only applies_to_os(os::Type{Windows}) = true
16-
@linux_only applies_to_os(os::Type{OSX}) = false
17-
@osx_only applies_to_os(os::Type{Linux}) = false
14+
15+
applies_to_os{U <: Unix}(os::Type{U}) = is_unix()
16+
applies_to_os(os::Type{Windows}) = is_windows()
17+
applies_to_os(os::Type{OSX}) = is_apple()
18+
applies_to_os(os::Type{Linux}) = is_linux()
1819

1920
function add_loadsave(format, predicates)
2021
library = shift!(predicates)
@@ -29,13 +30,13 @@ function add_loadsave(format, predicates)
2930
end
3031
end
3132

32-
@doc """
33+
"""
3334
`DataFormat{sym}()` indicates a known binary or text format of kind `sym`,
3435
where `sym` is always a symbol. For example, a .csv file might have
3536
`DataFormat{:CSV}()`.
3637
3738
An easy way to write `DataFormat{:CSV}` is `format"CSV"`.
38-
""" ->
39+
"""
3940
immutable DataFormat{sym} end
4041

4142
macro format_str(s)
@@ -44,8 +45,8 @@ end
4445

4546
const unknown_df = DataFormat{:UNKNOWN}
4647

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

@@ -63,7 +64,7 @@ function add_format(fmt, magic, extension, load_save_libraries...)
6364
fmt
6465
end
6566

66-
@doc """
67+
"""
6768
`add_format(fmt, magic, extention)` registers a new `DataFormat`.
6869
For example:
6970
@@ -72,7 +73,7 @@ For example:
7273
add_format(format"NRRD", "NRRD", [".nrrd",".nhdr"])
7374
7475
Note that extensions, magic numbers, and format-identifiers are case-sensitive.
75-
""" ->
76+
"""
7677
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,String}), extension)
7778
haskey(sym2info, sym) && error("format ", fmt, " is already registered")
7879
m = canonicalize_magic(magic)
@@ -112,9 +113,9 @@ function add_format{sym}(fmt::Type{DataFormat{sym}}, magic, extension)
112113
fmt
113114
end
114115

115-
@doc """
116+
"""
116117
`del_format(fmt::DataFormat)` deletes `fmt` from the format registry.
117-
""" ->
118+
"""
118119
function del_format{sym}(fmt::Type{DataFormat{sym}})
119120
magic, extension = sym2info[sym]
120121
del_magic(magic, sym)
@@ -147,9 +148,9 @@ function del_magic{N}(magic::NTuple{N, UInt8}, sym)
147148
nothing
148149
end
149150

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

155156

@@ -208,53 +209,53 @@ end
208209

209210
abstract Formatted{F<:DataFormat} # A specific file or stream
210211

211-
@doc """
212+
"""
212213
`File(fmt, filename)` indicates that `filename` is a file of known
213214
DataFormat `fmt`. For example, `File{fmtpng}(filename)` would indicate a PNG
214-
file.""" ->
215+
file."""
215216
immutable File{F<:DataFormat} <: Formatted{F}
216217
filename::Compat.UTF8String
217218
end
218219
File{sym}(fmt::Type{DataFormat{sym}}, filename) = File{fmt}(filename)
219220

220-
@doc """
221+
"""
221222
`filename(file)` returns the filename associated with `File` `file`.
222-
""" ->
223+
"""
223224
filename(f::File) = f.filename
224225

225-
@doc """
226+
"""
226227
`file_extension(file)` returns the file extension associated with `File` `file`.
227-
""" ->
228+
"""
228229
file_extension(f::File) = splitext(filename(f))[2]
229230

230231

231232

232-
@doc """
233+
"""
233234
`Stream(fmt, io, [filename])` indicates that the stream `io` is
234235
written in known `Format`. For example, `Stream{PNG}(io)` would
235236
indicate PNG format. If known, the optional `filename` argument can
236-
be used to improve error messages, etc.""" ->
237+
be used to improve error messages, etc."""
237238
immutable Stream{F<:DataFormat,IOtype<:IO} <: Formatted{F}
238239
io::IOtype
239240
filename::Nullable{Compat.UTF8String}
240241
end
241242

242243
Stream{F<:DataFormat}(::Type{F}, io::IO) = Stream{F,typeof(io)}(io, Nullable{Compat.UTF8String}())
243-
Stream{F<:DataFormat}(::Type{F}, io::IO, filename::AbstractString) = Stream{F,typeof(io)}(io,utf8(filename))
244+
Stream{F<:DataFormat}(::Type{F}, io::IO, filename::AbstractString) = Stream{F,typeof(io)}(io,Compat.UTF8String(filename))
244245
Stream{F<:DataFormat}(::Type{F}, io::IO, filename) = Stream{F,typeof(io)}(io,filename)
245246
Stream{F}(file::File{F}, io::IO) = Stream{F,typeof(io)}(io,filename(file))
246247

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

250-
@doc """
251+
"""
251252
`filename(stream)` returns a nullable-string of the filename
252-
associated with `Stream` `stream`.""" ->
253+
associated with `Stream` `stream`."""
253254
filename(s::Stream) = s.filename
254255

255-
@doc """
256+
"""
256257
`file_extension(file)` returns a nullable-string for the file extension associated with `Stream` `stream`.
257-
""" ->
258+
"""
258259
function file_extension(f::Stream)
259260
isnull(filename(f)) && return filename(f)
260261
splitext(get(filename(f)))[2]
@@ -300,13 +301,13 @@ Base.readbytes(s::Stream, nb) = read(stream(s), nb)
300301
Base.isreadonly(s::Stream) = isreadonly(stream(s))
301302
Base.isopen(s::Stream) = isopen(stream(s))
302303

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

306-
@doc """
307+
"""
307308
`skipmagic(s)` sets the position of `Stream` `s` to be just after the magic bytes.
308309
For a plain IO object, you can use `skipmagic(io, fmt)`.
309-
""" ->
310+
"""
310311
skipmagic{F}(s::Stream{F}) = (skipmagic(stream(s), F); s)
311312
function skipmagic{sym}(io, fmt::Type{DataFormat{sym}})
312313
magic, _ = sym2info[sym]
@@ -344,9 +345,9 @@ end
344345
unknown{F}(::File{F}) = unknown(F)
345346
unknown{F}(::Stream{F}) = unknown(F)
346347

347-
@doc """
348+
"""
348349
`query(filename)` returns a `File` object with information about the
349-
format inferred from the file's extension and/or magic bytes.""" ->
350+
format inferred from the file's extension and/or magic bytes."""
350351
function query(filename::AbstractString)
351352
_, ext = splitext(filename)
352353
if haskey(ext2sym, ext)
@@ -380,10 +381,10 @@ hasfunction(v::Vector) = any(hasfunction, v)
380381
hasfunction(s::Any) = true #has function
381382
hasfunction(s::Tuple) = false #has magic
382383

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

388389
function query(io::IO, filename::Nullable{Compat.UTF8String}=Nullable{Compat.UTF8String}())
389390
magic = Array(UInt8, 0)

src/registry.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ add_format(format"FLAC","fLaC",".flac",[:FLAC])
117117
# AVI is a subtype of RIFF, as is WAV
118118
function detectavi(io)
119119
seekstart(io)
120-
magic = ascii(read(io, UInt8, 4))
121-
magic == "RIFF" || return false
120+
magic = read(io, UInt8, 4)
121+
magic == b"RIFF" || return false
122122
seek(io, 8)
123-
submagic = ascii(read(io, UInt8, 4))
123+
submagic = read(io, UInt8, 4)
124124

125-
submagic == "AVI "
125+
submagic == b"AVI "
126126
end
127127
add_format(format"AVI", detectavi, ".avi", [:ImageMagick])
128128

0 commit comments

Comments
 (0)