Skip to content

Commit

Permalink
split keyword arguments (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 authored Oct 17, 2017
1 parent 8696f20 commit 2794d4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/CodecBzip2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ import TranscodingStreams:
initialize,
finalize

# TODO: This method will be added in the next version of TranscodingStreams.jl.
function splitkwargs(kwargs, keys)
hits = []
others = []
for kwarg in kwargs
push!(kwarg[1] keys ? hits : others, kwarg)
end
return hits, others
end

include("libbz2.jl")
include("compression.jl")
include("decompression.jl")

# Deprecations
@deprecate Bzip2Compression Bzip2Decompressor
@deprecate Bzip2Compression Bzip2Compressor
@deprecate Bzip2CompressionStream Bzip2CompressorStream
@deprecate Bzip2Decompression Bzip2Decompressor
@deprecate Bzip2DecompressionStream Bzip2DecompressorStream
Expand Down
3 changes: 2 additions & 1 deletion src/compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const Bzip2CompressorStream{S} = TranscodingStream{Bzip2Compressor,S} where S<:I
Create a bzip2 compression stream (see `Bzip2Compressor` for `kwargs`).
"""
function Bzip2CompressorStream(stream::IO; kwargs...)
return TranscodingStream(Bzip2Compressor(;kwargs...), stream)
x, y = splitkwargs(kwargs, (:blocksize100k, :workfactor, :verbosity))
return TranscodingStream(Bzip2Compressor(;x...), stream; y...)
end


Expand Down
3 changes: 2 additions & 1 deletion src/decompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const Bzip2DecompressorStream{S} = TranscodingStream{Bzip2Decompressor,S} where
Create a bzip2 decompression stream (see `Bzip2Decompressor` for `kwargs`).
"""
function Bzip2DecompressorStream(stream::IO; kwargs...)
return TranscodingStream(Bzip2Decompressor(;kwargs...), stream)
x, y = splitkwargs(kwargs, (:small, :verbosity))
return TranscodingStream(Bzip2Decompressor(;x...), stream; y...)
end


Expand Down

0 comments on commit 2794d4f

Please sign in to comment.