Skip to content

Commit

Permalink
toplev: Support .zst files for input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Sep 23, 2023
1 parent 3b3fb2d commit be9f3c1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tl_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def flex_open_r(fn):
if fn.endswith(".gz"):
gzip = popen_stdout(["gzip", "-d", "-c", fn])
return gzip.stdout
if fn.endswith(".zst"):
return popen_stdout(["zstd", "-d", "--stdout", fn]) .stdout
return open(fn, 'r')

def flex_open_w(fn):
Expand All @@ -42,6 +44,8 @@ def flex_open_w(fn):
if fn.endswith(".gz"):
gzip = popen_stdinout(["gzip", "-c"], f)
return gzip.stdin
if fn.endswith(".zst"):
return popen_stdinout(["zstd", "--stdout"], f).stdin
return f

test_mode = os.getenv("TL_TESTER")
Expand Down

0 comments on commit be9f3c1

Please sign in to comment.