You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a pretty straightforward update for the tarfile note:
basically copies the existing built-in methods, but there's room for improvement (mode a?) so i'm posting this as an issue for discussion, rather than a PR:
fromtarfileimportTarFile, CompressionError, ReadErrorclassTarZstFile(TarFile):
OPEN_METH= {
**TarFile.OPEN_METH,
'zst': 'zstopen'
}
@classmethoddefzstopen(cls, name, mode='r', fileobj=None, level_or_option=None, zstd_dict=None, **kwargs):
"""Open zstd compressed tar archive name for reading or writing. Appending is not allowed. """ifmodenotin ("r", "w", "x"):
raiseValueError("mode must be 'r', 'w' or 'x'")
try:
frompyzstdimportZstdFile, ZstdErrorexceptImportError:
raiseCompressionError("pyzstd module is not available") fromNonefileobj=ZstdFile(fileobjorname, mode, level_or_option=level_or_option, zstd_dict=zstd_dict)
try:
tar=cls.taropen(name, mode, fileobj, **kwargs)
except (ZstdError, EOFError) asexception:
fileobj.close()
ifmode=='r':
raiseReadError('not a zstd file') fromexceptionraiseexcept:
fileobj.close()
raisetar._extfileobj=Falsereturntar
a pretty straightforward update for the
tarfile
note:basically copies the existing built-in methods, but there's room for improvement (mode
a
?) so i'm posting this as an issue for discussion, rather than a PR:usage eg:
The text was updated successfully, but these errors were encountered: