Skip to content

Commit 5aacd67

Browse files
Add files via upload
1 parent 98af27b commit 5aacd67

1 file changed

Lines changed: 50 additions & 3 deletions

File tree

pyarchivefile.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def _get(section_dict, key, default=None):
610610
__version_date__ = str(__version_date_info__[0]) + "." + str(
611611
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
612612
__revision__ = __version_info__[3]
613-
__revision_id__ = "$Id: df415740ccda16ca0395e86ac4d28cf73a3eb9bf $"
613+
__revision_id__ = "$Id: 9573751580e57567307914cdb635c44931f78639 $"
614614
if(__version_info__[4] is not None):
615615
__version_date_plusrc__ = __version_date__ + \
616616
"-" + str(__version_date_info__[4])
@@ -2780,6 +2780,21 @@ def from_bytes(cls, data, mode='rb', **kw):
27802780
bio = io.BytesIO(bytes(data) if not isinstance(data, bytes) else data)
27812781
return cls(fileobj=bio, mode=mode, **kw)
27822782

2783+
# compatibility aliases for unwrapping utilities
2784+
@property
2785+
def fileobj(self):
2786+
return self.file
2787+
2788+
@property
2789+
def myfileobj(self):
2790+
return self.file
2791+
2792+
# if some code expects ._fp to be “the stream itself”:
2793+
@property
2794+
def _fp(self):
2795+
# OR return self.file if callers intend the raw file
2796+
return self
2797+
27832798
# ---------- Top-level helpers (optional) ----------
27842799
def decompress_bytes(blob, **kw):
27852800
"""
@@ -3228,6 +3243,21 @@ def from_bytes(cls, data, mode='rb', **kw):
32283243
bio = io.BytesIO(bytes(data) if not isinstance(data, bytes) else data)
32293244
return cls(fileobj=bio, mode=mode, **kw)
32303245

3246+
# compatibility aliases for unwrapping utilities
3247+
@property
3248+
def fileobj(self):
3249+
return self.file
3250+
3251+
@property
3252+
def myfileobj(self):
3253+
return self.file
3254+
3255+
# if some code expects ._fp to be “the stream itself”:
3256+
@property
3257+
def _fp(self):
3258+
# OR return self.file if callers intend the raw file
3259+
return self
3260+
32313261

32323262
# ---------- Top-level helpers ----------
32333263
def gzip_decompress_bytes(blob, mode='rb', multi=True, **kw):
@@ -3750,6 +3780,21 @@ def from_bytes(cls, data, mode='rb', **kw):
37503780
bio = io.BytesIO(bytes(data) if not isinstance(data, bytes) else data)
37513781
return cls(fileobj=bio, mode=mode, **kw)
37523782

3783+
# compatibility aliases for unwrapping utilities
3784+
@property
3785+
def fileobj(self):
3786+
return self.file
3787+
3788+
@property
3789+
def myfileobj(self):
3790+
return self.file
3791+
3792+
# if some code expects ._fp to be “the stream itself”:
3793+
@property
3794+
def _fp(self):
3795+
# OR return self.file if callers intend the raw file
3796+
return self
3797+
37533798

37543799
# ---------- Top-level helpers ----------
37553800
def lzop_compress_bytes(payload, level=9, text=False, **kw):
@@ -5882,7 +5927,6 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", filestart=0, seekstart=
58825927
infp.seek(oldinfppos, 0)
58835928
ArchiveList.append(ReadFileDataWithContentToArray(infp, currentinfilepos, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, informatspecs, seektoend))
58845929
currentinfilepos = infp.tell()
5885-
infp.close()
58865930
currentfilepos = fp.tell()
58875931
return ArchiveList
58885932

@@ -8903,7 +8947,10 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
89038947
return False
89048948

89058949
# Always operate on the raw source for probe/wrap
8906-
src = getattr(fp, "_fp", fp)
8950+
if hasattr(fp, "_fp"):
8951+
src = getattr(fp, "_fp", fp)
8952+
else:
8953+
src = fp
89078954

89088955
# Probe at filestart using RAW handle
89098956
try:

0 commit comments

Comments
 (0)