comp_size = cfg.compressed.stat().st_size
print(f"{cfg.compressed} size is {comp_size} bytes long")
if comp_size >= orig_size:
- sys.exit(
- f"sizeof({cfg.compressed}) == {comp_size} : "
- f"sizeof({cfg.orig}) == {orig_size}"
- )
+ sys.exit(f"sizeof({cfg.compressed}) == {comp_size} : sizeof({cfg.orig}) == {orig_size}")
start = cfg.compressed.open(mode="rb").read(5)
print(f"{cfg.compressed} starts with {start!r}")
if start != defs.MAGIC:
- sys.exit(
- f"{cfg.compressed} does not start with {defs.MAGIC!r}: {start!r}"
- )
+ sys.exit(f"{cfg.compressed} does not start with {defs.MAGIC!r}: {start!r}")
return comp_size
end=last_chunk.end + size,
)
if next_chunk.cend > comp_size:
- sys.exit(
- f"Compressed size overflow: {next_chunk.cend} > {comp_size}"
- )
+ sys.exit(f"Compressed size overflow: {next_chunk.cend} > {comp_size}")
more = idx + 1 != params["chunk_count"]
if more:
if next_chunk.end >= orig_size:
- sys.exit(
- f"Original size overflow: "
- f"{next_chunk.end} >= {orig_size}"
- )
+ sys.exit(f"Original size overflow: {next_chunk.end} >= {orig_size}")
else:
if next_chunk.cend != comp_size:
- sys.exit(
- f"Compressed size mismatch: "
- f"{next_chunk.cend} != {comp_size}"
- )
+ sys.exit(f"Compressed size mismatch: {next_chunk.cend} != {comp_size}")
if next_chunk.end != orig_size:
- sys.exit(
- f"Original size mismatch: "
- f"{next_chunk.end} != {orig_size}"
- )
+ sys.exit(f"Original size mismatch: {next_chunk.end} != {orig_size}")
print(f"- appending {next_chunk!r}")
chunks.append(next_chunk)
size = int(data.group("size"))
if size < 1 or size > comp_size:
- sys.exit(
- f"zck_read_header said data size {size} (comp {comp_size})"
- )
+ sys.exit(f"zck_read_header said data size {size} (comp {comp_size})")
params["size_diff"] = comp_size - size
return "wait_for_chunk_count"
"""Compile the test program."""
print("Fetching the C compiler flags for zck")
cflags = (
- subprocess.check_output(
- ["pkg-config", "--cflags", "zck"], shell=False, env=cfg.env
- )
+ subprocess.check_output(["pkg-config", "--cflags", "zck"], shell=False, env=cfg.env)
.decode("UTF-8")
.rstrip("\r\n")
)
print("Fetching the C linker flags and libraries for zck")
libs = (
- subprocess.check_output(
- ["pkg-config", "--libs", "zck"], shell=False, env=cfg.env
- )
+ subprocess.check_output(["pkg-config", "--libs", "zck"], shell=False, env=cfg.env)
.decode("UTF-8")
.rstrip("\r\n")
)
# OK, let's load it all into memory, mmkay?
contents = cfg.orig.read_bytes()
if len(contents) != orig_size:
- sys.exit(
- f"Could not read {orig_size} bytes from {cfg.orig}, "
- f"read {len(contents)}"
- )
+ sys.exit(f"Could not read {orig_size} bytes from {cfg.orig}, read {len(contents)}")
chunk = cfg.uncompressed.read_bytes()
if len(chunk) != second.size:
- sys.exit(
- f"Could not read {second.size} bytes from {cfg.uncompressed}, "
- f"read {len(chunk)}"
- )
+ sys.exit(f"Could not read {second.size} bytes from {cfg.uncompressed}, read {len(chunk)}")
if contents[second.start : second.start + second.size] != chunk:
sys.exit("Mismatch!")
sys.exit(f"Uncompressed size {new_size} != original size {orig_size}")
print(f"Comparing {cfg.orig} to {cfg.uncompressed}")
- subprocess.check_call(
- ["cmp", "--", cfg.orig, cfg.uncompressed], shell=False, env=cfg.env
- )
+ subprocess.check_call(["cmp", "--", cfg.orig, cfg.uncompressed], shell=False, env=cfg.env)
def do_recompress(cfg: Config, comp_size: int) -> None:
new_size = cfg.recompressed.stat().st_size
print(f"Recompressed size {new_size}")
if new_size != comp_size:
- sys.exit(
- f"Recompressed size {new_size} != compressed size {comp_size}"
- )
+ sys.exit(f"Recompressed size {new_size} != compressed size {comp_size}")
print(f"Comparing {cfg.compressed} to {cfg.recompressed}")
subprocess.check_call(
[tool.black]
-line-length = 79
+line-length = 100
[tool.mypy]
strict = true
[flake8]
# Leave the formatting to the black tool.
extend-ignore = E203
+max-line-length = 100