Skip to content

Commit cd3c197

Browse files
Add files via upload
1 parent 8c9290d commit cd3c197

1 file changed

Lines changed: 50 additions & 3 deletions

File tree

pycatfile.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def _get(section_dict, key, default=None):
622622
__version_date__ = str(__version_date_info__[0]) + "." + str(
623623
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
624624
__revision__ = __version_info__[3]
625-
__revision_id__ = "$Id: b49a691e7b814a957c65b7e6859ae0670540456f $"
625+
__revision_id__ = "$Id: 340d37e5ca55078bf9f8c592ea941149b29caab1 $"
626626
if(__version_info__[4] is not None):
627627
__version_date_plusrc__ = __version_date__ + \
628628
"-" + str(__version_date_info__[4])
@@ -2792,6 +2792,21 @@ def from_bytes(cls, data, mode='rb', **kw):
27922792
bio = io.BytesIO(bytes(data) if not isinstance(data, bytes) else data)
27932793
return cls(fileobj=bio, mode=mode, **kw)
27942794

2795+
# compatibility aliases for unwrapping utilities
2796+
@property
2797+
def fileobj(self):
2798+
return self.file
2799+
2800+
@property
2801+
def myfileobj(self):
2802+
return self.file
2803+
2804+
# if some code expects ._fp to be “the stream itself”:
2805+
@property
2806+
def _fp(self):
2807+
# OR return self.file if callers intend the raw file
2808+
return self
2809+
27952810
# ---------- Top-level helpers (optional) ----------
27962811
def decompress_bytes(blob, **kw):
27972812
"""
@@ -3240,6 +3255,21 @@ def from_bytes(cls, data, mode='rb', **kw):
32403255
bio = io.BytesIO(bytes(data) if not isinstance(data, bytes) else data)
32413256
return cls(fileobj=bio, mode=mode, **kw)
32423257

3258+
# compatibility aliases for unwrapping utilities
3259+
@property
3260+
def fileobj(self):
3261+
return self.file
3262+
3263+
@property
3264+
def myfileobj(self):
3265+
return self.file
3266+
3267+
# if some code expects ._fp to be “the stream itself”:
3268+
@property
3269+
def _fp(self):
3270+
# OR return self.file if callers intend the raw file
3271+
return self
3272+
32433273

32443274
# ---------- Top-level helpers ----------
32453275
def gzip_decompress_bytes(blob, mode='rb', multi=True, **kw):
@@ -3762,6 +3792,21 @@ def from_bytes(cls, data, mode='rb', **kw):
37623792
bio = io.BytesIO(bytes(data) if not isinstance(data, bytes) else data)
37633793
return cls(fileobj=bio, mode=mode, **kw)
37643794

3795+
# compatibility aliases for unwrapping utilities
3796+
@property
3797+
def fileobj(self):
3798+
return self.file
3799+
3800+
@property
3801+
def myfileobj(self):
3802+
return self.file
3803+
3804+
# if some code expects ._fp to be “the stream itself”:
3805+
@property
3806+
def _fp(self):
3807+
# OR return self.file if callers intend the raw file
3808+
return self
3809+
37653810

37663811
# ---------- Top-level helpers ----------
37673812
def lzop_compress_bytes(payload, level=9, text=False, **kw):
@@ -5894,7 +5939,6 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", filestart=0, seekstart=
58945939
infp.seek(oldinfppos, 0)
58955940
ArchiveList.append(ReadFileDataWithContentToArray(infp, currentinfilepos, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, informatspecs, seektoend))
58965941
currentinfilepos = infp.tell()
5897-
infp.close()
58985942
currentfilepos = fp.tell()
58995943
return ArchiveList
59005944

@@ -8915,7 +8959,10 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
89158959
return False
89168960

89178961
# Always operate on the raw source for probe/wrap
8918-
src = getattr(fp, "_fp", fp)
8962+
if hasattr(fp, "_fp"):
8963+
src = getattr(fp, "_fp", fp)
8964+
else:
8965+
src = fp
89198966

89208967
# Probe at filestart using RAW handle
89218968
try:

0 commit comments

Comments
 (0)