Skip to content

Commit 83d06e4

Browse files
authored
Add files via upload
1 parent 17b3067 commit 83d06e4

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

pyfoxfile.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8837,6 +8837,14 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
88378837
if not hasattr(fp, "read"):
88388838
return False
88398839

8840+
# If caller already gave us a FileLikeAdapter => honor it and return it.
8841+
if isinstance(fp, FileLikeAdapter):
8842+
try:
8843+
fp.write_through = True
8844+
except Exception:
8845+
pass
8846+
return fp
8847+
88408848
# Detect format on the fileobj at filestart
88418849
compresscheck = CheckCompressionType(fp, formatspecs, filestart, False)
88428850
if IsNestedDict(formatspecs) and compresscheck in formatspecs:
@@ -8886,15 +8894,8 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
88868894

88878895
return FileLikeAdapter(fp, mode="rb", mm=mm)
88888896

8889-
def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
8890-
use_mmap=False):
8891-
"""
8892-
Accepts an already-open *bytes* file-like (fp). Detects compression and
8893-
returns a FileLikeAdapter opened for 'rb'. If the stream is uncompressed
8894-
and backed by a real file, you can enable mmap via use_mmap=True.
8895-
"""
8896-
if not hasattr(fp, "read"):
8897-
return False
8897+
def UncompressFile(infile, formatspecs=__file_format_multi_dict__, mode="rb",
8898+
filestart=0, use_mmap=False):
88988899

88998900
# If caller already gave us a FileLikeAdapter => honor it and return it.
89008901
if isinstance(fp, FileLikeAdapter):
@@ -8903,6 +8904,7 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
89038904
except Exception:
89048905
pass
89058906
return fp
8907+
89068908
"""
89078909
Opens a path, detects compression by header, and returns a FileLikeAdapter.
89088910
If uncompressed and use_mmap=True, returns an mmap-backed reader.
@@ -9647,6 +9649,14 @@ def CompressOpenFile(outfile, compressionenable=True, compressionlevel=None,
96479649
if outfile is None:
96489650
return False
96499651

9652+
# If caller already gave us a FileLikeAdapter => honor it and return it.
9653+
if isinstance(fp, FileLikeAdapter):
9654+
try:
9655+
fp.write_through = True
9656+
except Exception:
9657+
pass
9658+
return fp
9659+
96509660
fbasename, fextname = os.path.splitext(outfile)
96519661
compressionlevel = 9 if compressionlevel is None else int(compressionlevel)
96529662
mode = "w" if PY2 else "wb"

0 commit comments

Comments
 (0)