Option to deflate TRX files created with Python
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu trong tff_convert_tractogram.py, sử dụng các tùy chọn --positions_dtype và --offsets_dtype hiện có để xác định nơi các tệp ZIP TRX được tạo. Xem lại các tùy chọn nén của zipfile trong Python và ví dụ zip2zip.py của issue. Hoàn thành khi công cụ có thể chọn kiểu nén stored hoặc deflate với một mức có thể cấu hình, đồng thời giữ nguyên hành vi hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I find the tff_convert_tractogram.py tool useful, and it provides options for both --positions_dtype and --offsets_dtype. However, the TRX zip files are always uncompressed (store) rather than using compression (some level of deflate). It might be nice to trade off file creation speed with file size (and transmission time).
I did write a little Python script to do this, but it would be nice to integrate this. My standalone script allows you to recompress any zip file (including trx) with a desired compression level:
python zip2zip.py -c 9 IFOF_L32.trx IFOF_L32_z9.trx
The code is:
import zipfile
import argparse
import sys
def recompress_zip(input_zip: str, output_zip: str, compression_level: int):
"""Recompress a ZIP file with a specified compression level (0-9)."""
compression_type = zipfile.ZIP_DEFLATED if compression_level > 0 else zipfile.ZIP_STORED
with zipfile.ZipFile(input_zip, 'r') as src_zip:
with zipfile.ZipFile(output_zip, 'w', compression=compression_type, compresslevel=compression_level) as dst_zip:
for file_info in src_zip.infolist():
with src_zip.open(file_info.filename, 'r') as src_file:
dst_zip.writestr(file_info, src_file.read(), compress_type=compression_type)
print(f"Recompressed {input_zip} -> {output_zip} with compression level {compression_level}")
def main():
parser = argparse.ArgumentParser(description="Recompress a ZIP file with a specified compression level.")
parser.add_argument("input_zip", help="Path to the input ZIP file")
parser.add_argument("output_zip", help="Path to the output compressed ZIP file")
parser.add_argument("-c", "--compression", type=int, choices=range(0, 10), default=9,
help="Compression level (0-9, where 0 is uncompressed and 9 is max compression, default: 9)")
args = parser.parse_args()
try:
recompress_zip(args.input_zip, args.output_zip, args.compression)
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()
- Ngôn ngữ chính
- Python
- Star
- 27
- Fork
- 20
- Merge trung bình
- 2 ngày 25 phút
- Pull request đã merge (30 ngày)
- 1
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tee-ar-ex/trx-python
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
tee-ar-ex/trx-python#77 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tee-ar-ex/trx-python#72 · 3 bình luận ·
-
Circular Dependency for DIPY ?Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tee-ar-ex/trx-python#51 · 23 bình luận ·
-
Allow other types into `append`Đang mởgood first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
tee-ar-ex/trx-python#39 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tee-ar-ex/trx-python#21 · 4 bình luận ·
Tất cả issue của tee-ar-ex/trx-python
Issue tương tự
-
customer-reported question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Azure/azure-sdk-for-python#49548 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
btclib-org/btclib-wallet#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Phase 2 PSA Capability & Career Profile
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fastmachinelearning/hls4ml#1582 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Sort modelsĐang mởenhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày