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 19, 2017
1 parent b231e33 commit 32c01b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/CodecXz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ 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("liblzma.jl")
include("compression.jl")
include("decompression.jl")
Expand Down
3 changes: 2 additions & 1 deletion src/compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const XzCompressorStream{S} = TranscodingStream{XzCompressor,S} where S<:IO
Create an xz compression stream (see `XzCompressor` for `kwargs`).
"""
function XzCompressorStream(stream::IO; kwargs...)
return TranscodingStream(XzCompressor(;kwargs...), stream)
x, y = splitkwargs(kwargs, (:level, :check))
return TranscodingStream(XzCompressor(;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 @@ -39,7 +39,8 @@ const XzDecompressorStream{S} = TranscodingStream{XzDecompressor,S} where S<:IO
Create an xz decompression stream (see `XzDecompressor` for `kwargs`).
"""
function XzDecompressorStream(stream::IO; kwargs...)
return TranscodingStream(XzDecompressor(;kwargs...), stream)
x, y = splitkwargs(kwargs, (:memlimit, :flags))
return TranscodingStream(XzDecompressor(;x...), stream; y...)
end


Expand Down

0 comments on commit 32c01b1

Please sign in to comment.