BioJulia / Libz.jl

Fast, flexible zlib bindings.
Other
27 stars 17 forks source link

Convenience functions for dealing with .gz files #12

Closed samoconnor closed 8 years ago

samoconnor commented 8 years ago

Convenience functions to read/write directly from/to a named file.

I'm doing a cleanup of my local stash of convenience functions and thought that these might be generally useful.

gzwrite("/tmp/foo.gz", "hello")
gzreadall("/tmp/foo.gz")
"hello"

See also https://github.com/JuliaLang/GZip.jl/pull/45#issuecomment-169565175

Also, the example in README.md doesn't work...

stream = open("data.txt.gz", "w") |> ZlibDeflateOutputStream
for c in rand(UInt8, 10000)
    write(stream, c)
end
close(stream)

The underlying file needs to be closed to ensure that the file is completely written...

io = open("data.txt.gz", "w")
stream = ZlibDeflateOutputStream(io)
for c in rand(UInt8, 10000)
    write(stream, c)
end
close(stream)
close(io)

The gzopen(::Function...) methods in the PR make this easier by supporting gzopen("foo.gz") do io... syntax.

codecov-io commented 8 years ago

Current coverage is 77.00%

Merging #12 into master will increase coverage by +3.41% as of c43f8db

@@            master    #12   diff @@
=====================================
  Files            5      5       
  Stmts          178    187     +9
  Branches         0      0       
  Methods          0      0       
=====================================
+ Hit            131    144    +13
  Partial          0      0       
+ Missed          47     43     -4

Review entire Coverage Diff as of c43f8db

Powered by Codecov. Updated on successful CI builds.

tkelman commented 8 years ago

You can't export the same names from multiple packages.

samoconnor commented 8 years ago

Hi @tkelman, re name clash across packages: @kmsquire suggested that Gzip.jl is depricated-ish in favour of Libz.jl, so I move the PR over to here.

More generally though, I imagine that its a useful pattern to have the same names from multiple packages if they really do the same thing. That would allow easy plug ability of alternate implementations.

tkelman commented 8 years ago

Except that packages aren't always exactly drop in replacements (if they were they'd just be new versions instead of separate packages), and different downstream users have different requirements, including the ability to use both simultaneously.

tkelman commented 8 years ago

If you want to extend the same generic function with new methods that makes complete sense, but you have to agree where the generic function is defined and extended from, and use completely disjoint type signatures for all methods.

samoconnor commented 8 years ago

bump

https://github.com/JuliaLang/julia/pull/14660 is now merged

This PR makes the gz interface more consistent with ::IO is base.

TransGirlCodes commented 8 years ago

Awesome! Is there any chance of increasing the code coverage a bit before a merge? codecov is telling me it has fallen as a result of the PR.

samoconnor commented 8 years ago

any chance of increasing the code coverage a bit before a merge?

done

blahah commented 8 years ago

@samoconnor that was fast!

if CI checks pass, LGTM :shipit:

TransGirlCodes commented 8 years ago

Only appveyor fails, but it was failing before. I don't think it's a PR specific failing. :shipit: