Skip to content

Commit c65ab5b

Browse files
committed
Merge pull request #33 from JuliaIO/sd/depwarns
removed depwarns
2 parents ee39242 + 91d46a3 commit c65ab5b

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

src/FileIO.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
VERSION >= v"0.4.0-dev+6641" && __precompile__()
22

33
module FileIO
4+
using Compat
45

56
if VERSION < v"0.4.0-dev"
6-
using Docile, Compat
7+
using Docile
78
immutable Pair{A,B}
89
first::A
910
second::B
@@ -46,7 +47,7 @@ the magic bytes are essential.
4647
- `load(File(format"PNG",filename))` specifies the format directly, and bypasses inference.
4748
- `load(f; options...)` passes keyword arguments on to the loader.
4849
""" ->
49-
function load(s::Union(AbstractString,IO), args...; options...)
50+
function load(s::@compat(Union{AbstractString,IO}), args...; options...)
5051
q = query(s)
5152
check_loader(q)
5253
load(q, args...; options...)
@@ -58,7 +59,7 @@ trying to infer the format from `filename`.
5859
- `save(Stream(format"PNG",io), data...)` specifies the format directly, and bypasses inference.
5960
- `save(f, data...; options...)` passes keyword arguments on to the saver.
6061
""" ->
61-
function save(s::Union(AbstractString,IO), data...; options...)
62+
function save(s::@compat(Union{AbstractString,IO}), data...; options...)
6263
q = query(s)
6364
check_saver(q)
6465
save(q, data...; options...)

src/query.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const unknown_df = DataFormat{:UNKNOWN}
2020
unknown(::Type{format"UNKNOWN"}) = true
2121
unknown{sym}(::Type{DataFormat{sym}}) = false
2222

23-
const ext2sym = Dict{ASCIIString,Union(Symbol,Vector{Symbol})}()
23+
const ext2sym = Dict{ASCIIString, @compat(Union{Symbol,Vector{Symbol}})}()
2424
const magic_list = Array(Pair, 0) # sorted, see magic_cmp below
2525
const sym2info = Dict{Symbol,Any}() # Symbol=>(magic, extension)
2626
const magic_func = Array(Pair, 0) # for formats with complex magic #s
@@ -35,7 +35,7 @@ For example:
3535
3636
Note that extensions, magic numbers, and format-identifiers are case-sensitive.
3737
""" ->
38-
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::Union(Tuple,AbstractVector,ByteString), extension)
38+
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,ByteString}), extension)
3939
haskey(sym2info, sym) && error("format ", fmt, " is already registered")
4040
m = canonicalize_magic(magic)
4141
rng = searchsorted(magic_list, m, lt=magic_cmp)
@@ -49,7 +49,7 @@ function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::Union(Tuple,Abstract
4949
end
5050

5151
# for multiple magic bytes
52-
function add_format{sym, T <: Vector{Uint8}, N}(fmt::Type{DataFormat{sym}}, magics::NTuple{N, T}, extension)
52+
function add_format{sym, T <: Vector{UInt8}, N}(fmt::Type{DataFormat{sym}}, magics::NTuple{N, T}, extension)
5353
haskey(sym2info, sym) && error("format ", fmt, " is already registered")
5454
magics = map(canonicalize_magic, magics)
5555
for magic in magics
@@ -90,7 +90,7 @@ del_magic(magic::Tuple, sym) = for m in magic
9090
del_magic(m, sym)
9191
end
9292
# Deletes single magic bytes
93-
function del_magic{N}(magic::NTuple{N, Uint8}, sym)
93+
function del_magic{N}(magic::NTuple{N, UInt8}, sym)
9494
rng = searchsorted(magic_list, magic, lt=magic_cmp)
9595
if length(magic) == 0
9696
fullrng = rng
@@ -133,14 +133,14 @@ function add_extension(ext::ASCIIString, sym)
133133
end
134134
ext2sym[ext] = sym
135135
end
136-
function add_extension(ext::Union(Array,Tuple), sym)
136+
function add_extension(ext::@compat(Union{Array,Tuple}), sym)
137137
for e in ext
138138
add_extension(e, sym)
139139
end
140140
end
141141

142142
del_extension(ext::ASCIIString) = delete!(ext2sym, ext)
143-
function del_extension(ext::Union(Array,Tuple))
143+
function del_extension(ext::@compat(Union{Array,Tuple}))
144144
for e in ext
145145
del_extension(e)
146146
end

src/registry.jl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ add_format(format"WPG", UInt8[0xff,0x57,0x50,0x43], ".wpg")
8989
add_loader(format"WPG", :ImageMagick)
9090
add_saver(format"WPG", :ImageMagick)
9191

92+
#=
93+
add_format(format"NPY", UInt8[0x93, 'N', 'U', 'M', 'P', 'Y'], ".npy")
94+
add_loader(format"NPZ", :NPZ)
95+
add_saver(format"NPZ", :NPZ)
96+
97+
add_format(format"ZIP", [0x50,0x4b,0x03,0x04], ".zip")
98+
add_loader(format"ZIP", :ZipeFile)
99+
add_saver(format"ZIP", :ZipeFile)
100+
=#
101+
92102
#Shader files
93103
add_format(format"GLSLShader", (), [".frag", ".vert", ".geom", ".comp"])
94104
add_loader(format"GLSLShader", :GLAbstraction)
@@ -117,7 +127,6 @@ add_saver(format"OFF", :MeshIO)
117127

118128

119129

120-
121130
### Complex cases
122131
# HDF5: the complication is that the magic bytes may start at
123132
# 0, 512, 1024, 2048, or any multiple of 2 thereafter
@@ -161,8 +170,8 @@ function detect_stlascii(io)
161170
end
162171
end
163172
function detect_stlbinary(io)
164-
const size_header = 80+sizeof(Uint32)
165-
const size_triangleblock = (4*3*sizeof(Float32)) + sizeof(Uint16)
173+
const size_header = 80+sizeof(UInt32)
174+
const size_triangleblock = (4*3*sizeof(Float32)) + sizeof(UInt16)
166175

167176
position(io) != 0 && (seekstart(io); return false)
168177
seekend(io)
@@ -171,12 +180,12 @@ function detect_stlbinary(io)
171180
len < size_header && return false
172181

173182
skip(io, 80) # skip header
174-
number_of_triangle_blocks = read(io, Uint32)
183+
number_of_triangle_blocks = read(io, UInt32)
175184
#1 normal, 3 vertices in Float32 + attrib count, usually 0
176185
len != (number_of_triangle_blocks*size_triangleblock)+size_header && (seekstart(io); return false)
177-
skip(io, number_of_triangle_blocks*size_triangleblock-sizeof(Uint16))
178-
attrib_byte_count = read(io, Uint16) # read last attrib_byte
179-
attrib_byte_count != zero(Uint16) && (seekstart(io); return false) # should be zero as not used
186+
skip(io, number_of_triangle_blocks*size_triangleblock-sizeof(UInt16))
187+
attrib_byte_count = read(io, UInt16) # read last attrib_byte
188+
attrib_byte_count != zero(UInt16) && (seekstart(io); return false) # should be zero as not used
180189
result = eof(io) # if end of file, we have a stl!
181190
seekstart(io)
182191
return result

0 commit comments

Comments
 (0)