feat(mlg): write .MLG files as Blastware does; retire the old writer
mlg_bytes()/write_mlg() rebuild all 12 fixture files byte for byte: little-endian times, length-led records, each record's checksum. The old blastware_file writer (big-endian times, a zero CRC at the wrong end, 308- byte header) and the read_mlg stub are removed; nothing called them. No re-export: event_file_io imports blastware_file, and mlg_file imports event_file_io. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
This commit is contained in:
1 parent
3cd95db405
commit
a8adb03d23
3 files changed
+70
-220
No files matched your search
+21
-1
@@ -22,7 +22,7 @@ import pytest
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from minimateplus.crc import crc16_aug_ccitt
|
||||
from minimateplus.mlg_file import MlgFormatError, parse_mlg, read_mlg
|
||||
from minimateplus.mlg_file import MlgFormatError, mlg_bytes, parse_mlg, read_mlg, write_mlg
|
||||
|
||||
FIX = Path(__file__).parent / "fixtures" / "mlg-11-9-26"
|
||||
dt = datetime.datetime
|
||||
@@ -108,3 +108,23 @@ def test_a_flipped_byte_in_the_header_record_is_reported():
|
||||
def test_structure_errors_raise(mangle):
|
||||
with pytest.raises(MlgFormatError):
|
||||
parse_mlg(mangle((FIX / "BE128443065.MLG").read_bytes()))
|
||||
|
||||
|
||||
# ── Writer ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@pytest.mark.parametrize("name", sorted(p.name for p in FIX.glob("*.MLG")))
|
||||
def test_rebuilds_every_fixture_byte_for_byte(name):
|
||||
raw = (FIX / name).read_bytes()
|
||||
assert mlg_bytes(parse_mlg(raw)) == raw
|
||||
|
||||
|
||||
def test_write_mlg_writes_the_same_bytes(tmp_path):
|
||||
raw = (FIX / "BE8081321.MLG").read_bytes()
|
||||
out = tmp_path / "BE8081321.MLG"
|
||||
write_mlg(parse_mlg(raw), out)
|
||||
assert out.read_bytes() == raw
|
||||
|
||||
|
||||
def test_old_mlg_code_is_gone():
|
||||
import minimateplus.blastware_file as bw
|
||||
assert not hasattr(bw, "read_mlg") and not hasattr(bw, "MLG_FLAGS_TRIGGER")
|
||||
Reference in new issue
Block a user