should `load(::Stream, ...)` methods skip magic bytes?

Đang mở
#163 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@ssfrr đang làm issue này rồi.

Từ ngày 20/3/2018.

  • #177 của @ssfrr — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
julia
Lĩnh vực
documentation

Hướng nghiên cứu

Đọc ví dụ tải stream trong README và kiểm tra bài kiểm thử ImageMagick.jl được liên kết tại test/constructed_images.jl, các dòng 195-201. Xác nhận vị trí dự kiến của stream khi load(::Stream) được gọi, sau đó cập nhật README để nêu rõ contract và cách sử dụng nếu các maintainers xác nhận điều đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

In the README, the example for loading from a stream is:

function load(f::File{format"PNG"})
  open(f) do s
  skipmagic(s) # skip over the magic bytes
  # You can just call the method below...
  ret = load(s)
  # ...or implement everything here instead
  end
end

# You can support streams and add keywords:
function load(s::Stream{format"PNG"}; keywords...)
  # s is already positioned after the magic bytes
  # Do the stuff to read a PNG file
  chunklength = read(s, UInt32)
  ...
end

This works if the user calls load("somefile.png"), which will end up calling the load(::File, ...) method, which handles skipping the magic bytes before calling load(::Stream). What I'm not super clear on is how this is intended to be used directly. e.g. I couldn't just do:

open("somefile.png") do io
    load(io)
end

In ImageMagick.jl it looks like load is called on the IO stream directly without skipping the magic(k) bytes.

So if it seems like the way ImageMagick does it (leaving the stream at the very beginning of the file when calling load(::Stream)) I can put in a documentation PR that clarifies that.

Ngôn ngữ chính
Julia
Star
228
Fork
83
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JuliaIO/FileIO.jl

Tất cả issue của JuliaIO/FileIO.jl

Issue tương tự

Thêm issue về Julia

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.