From b94904f5ee6a20f15019b8d2d61daedf3c919167 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Tue, 28 Feb 2023 22:53:06 +0000 Subject: [PATCH] core.kompress: support .zst extension, seems more conventional than .zstd --- my/core/kompress.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/my/core/kompress.py b/my/core/kompress.py index 26e0bbd..9b8a40f 100644 --- a/my/core/kompress.py +++ b/my/core/kompress.py @@ -18,13 +18,14 @@ class Ext: zip = '.zip' lz4 = '.lz4' zstd = '.zstd' + zst = '.zst' targz = '.tar.gz' def is_compressed(p: Path) -> bool: # todo kinda lame way for now.. use mime ideally? # should cooperate with kompress.kopen? - return any(p.name.endswith(ext) for ext in {Ext.xz, Ext.zip, Ext.lz4, Ext.zstd, Ext.targz}) + return any(p.name.endswith(ext) for ext in {Ext.xz, Ext.zip, Ext.lz4, Ext.zstd, Ext.zst, Ext.targz}) def _zstd_open(path: Path, *args, **kwargs) -> IO[str]: @@ -70,7 +71,7 @@ def kopen(path: PathIsh, *args, mode: str='rt', **kwargs) -> IO[str]: elif name.endswith(Ext.lz4): import lz4.frame # type: ignore return lz4.frame.open(str(pp), mode, *args, **kwargs) - elif name.endswith(Ext.zstd): + elif name.endswith(Ext.zstd) or name.endswith(Ext.zst): return _zstd_open(pp, mode, *args, **kwargs) elif name.endswith(Ext.targz): import tarfile