PyCatFile 0.15.16__tar.gz → 0.15.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycatfile-0.15.16 → pycatfile-0.15.18}/PKG-INFO +1 -1
- {pycatfile-0.15.16 → pycatfile-0.15.18}/PyCatFile.egg-info/PKG-INFO +1 -1
- {pycatfile-0.15.16 → pycatfile-0.15.18}/pycatfile.py +286 -88
- {pycatfile-0.15.16 → pycatfile-0.15.18}/LICENSE +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/PyCatFile.egg-info/SOURCES.txt +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/PyCatFile.egg-info/dependency_links.txt +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/PyCatFile.egg-info/top_level.txt +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/PyCatFile.egg-info/zip-safe +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/README.md +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/catfile.py +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/neocatfile.py +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/setup.cfg +0 -0
- {pycatfile-0.15.16 → pycatfile-0.15.18}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.18
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.18
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: pycatfile.py - Last Update: 12/
|
|
17
|
+
$FileInfo: pycatfile.py - Last Update: 12/26/2024 Ver. 0.15.18 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -314,12 +314,12 @@ __file_format_dict__ = {'format_name': __file_format_name__, 'format_magic': __f
|
|
|
314
314
|
'format_delimiter': __file_format_delimiter__, 'format_ver': __file_format_ver__, 'new_style': __use_new_style__, 'use_advanced_list': __use_advanced_list__, 'use_alt_inode': __use_alt_inode__}
|
|
315
315
|
__project__ = __program_name__
|
|
316
316
|
__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
|
|
317
|
-
__version_info__ = (0, 15,
|
|
318
|
-
__version_date_info__ = (2024, 12,
|
|
317
|
+
__version_info__ = (0, 15, 18, "RC 1", 1)
|
|
318
|
+
__version_date_info__ = (2024, 12, 26, "RC 1", 1)
|
|
319
319
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
320
320
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
321
321
|
__revision__ = __version_info__[3]
|
|
322
|
-
__revision_id__ = "$Id:
|
|
322
|
+
__revision_id__ = "$Id: 64d8dc9d309e4604a335dee0bc50e5679540be3f $"
|
|
323
323
|
if(__version_info__[4] is not None):
|
|
324
324
|
__version_date_plusrc__ = __version_date__ + \
|
|
325
325
|
"-" + str(__version_date_info__[4])
|
|
@@ -386,6 +386,7 @@ except ImportError:
|
|
|
386
386
|
pass
|
|
387
387
|
try:
|
|
388
388
|
import zstandard
|
|
389
|
+
compressionsupport.append("zst")
|
|
389
390
|
compressionsupport.append("zstd")
|
|
390
391
|
compressionsupport.append("zstandard")
|
|
391
392
|
except ImportError:
|
|
@@ -402,6 +403,8 @@ except ImportError:
|
|
|
402
403
|
except ImportError:
|
|
403
404
|
pass
|
|
404
405
|
compressionsupport.append("zlib")
|
|
406
|
+
compressionsupport.append("zl")
|
|
407
|
+
compressionsupport.append("zz")
|
|
405
408
|
|
|
406
409
|
compressionlist = ['auto']
|
|
407
410
|
compressionlistalt = []
|
|
@@ -1003,6 +1006,193 @@ class GzipFile:
|
|
|
1003
1006
|
self.close()
|
|
1004
1007
|
|
|
1005
1008
|
|
|
1009
|
+
class ZstdFile(object):
|
|
1010
|
+
ZSTD_MAGIC = b'\x28\xb5\x2f\xfd' # Zstandard magic bytes
|
|
1011
|
+
|
|
1012
|
+
def __init__(self, file_path=None, fileobj=None, mode='rb', level=9,
|
|
1013
|
+
encoding=None, errors=None, newline=None):
|
|
1014
|
+
"""
|
|
1015
|
+
A file-like wrapper around Zstandard compression/decompression,
|
|
1016
|
+
supporting both Python 2 and 3.
|
|
1017
|
+
"""
|
|
1018
|
+
if file_path is None and fileobj is None:
|
|
1019
|
+
raise ValueError("Either file_path or fileobj must be provided")
|
|
1020
|
+
if file_path is not None and fileobj is not None:
|
|
1021
|
+
raise ValueError("Only one of file_path or fileobj should be provided")
|
|
1022
|
+
|
|
1023
|
+
self.file_path = file_path
|
|
1024
|
+
self.fileobj = fileobj
|
|
1025
|
+
self.mode = mode
|
|
1026
|
+
self.level = level
|
|
1027
|
+
self.encoding = encoding
|
|
1028
|
+
self.errors = errors
|
|
1029
|
+
self.newline = newline
|
|
1030
|
+
self._compressed_data = b''
|
|
1031
|
+
self._decompressed_data = b''
|
|
1032
|
+
self._position = 0
|
|
1033
|
+
|
|
1034
|
+
# Track whether we're doing text mode
|
|
1035
|
+
self._text_mode = 't' in mode
|
|
1036
|
+
|
|
1037
|
+
# Force binary mode internally for reading/writing bytes
|
|
1038
|
+
internal_mode = mode.replace('t', 'b')
|
|
1039
|
+
|
|
1040
|
+
if 'w' in mode or 'a' in mode or 'x' in mode:
|
|
1041
|
+
# Open the file if a path was specified; otherwise, use fileobj
|
|
1042
|
+
if file_path:
|
|
1043
|
+
self.file = open(file_path, internal_mode)
|
|
1044
|
+
else:
|
|
1045
|
+
self.file = fileobj
|
|
1046
|
+
|
|
1047
|
+
# Create a ZstdCompressor, then obtain a compressobj for flushing
|
|
1048
|
+
zctx = zstandard.ZstdCompressor(level=self.level)
|
|
1049
|
+
self._compressor = zctx.compressobj()
|
|
1050
|
+
|
|
1051
|
+
elif 'r' in mode:
|
|
1052
|
+
if file_path:
|
|
1053
|
+
if os.path.exists(file_path):
|
|
1054
|
+
self.file = open(file_path, internal_mode)
|
|
1055
|
+
self._load_file()
|
|
1056
|
+
else:
|
|
1057
|
+
raise FileNotFoundError("No such file: '{}'".format(file_path))
|
|
1058
|
+
else:
|
|
1059
|
+
# fileobj provided
|
|
1060
|
+
self.file = fileobj
|
|
1061
|
+
self._load_file()
|
|
1062
|
+
|
|
1063
|
+
else:
|
|
1064
|
+
raise ValueError("Mode should be 'rb'/'rt' or 'wb'/'wt'")
|
|
1065
|
+
|
|
1066
|
+
def _load_file(self):
|
|
1067
|
+
"""
|
|
1068
|
+
Reads the entire compressed file into memory and uses streaming
|
|
1069
|
+
decompression to handle multiple frames or frames with unknown size.
|
|
1070
|
+
"""
|
|
1071
|
+
self.file.seek(0)
|
|
1072
|
+
self._compressed_data = self.file.read()
|
|
1073
|
+
|
|
1074
|
+
# Validate Zstd magic bytes at the start
|
|
1075
|
+
if not self._compressed_data.startswith(self.ZSTD_MAGIC):
|
|
1076
|
+
raise ValueError("Invalid Zstandard file header (magic bytes missing)")
|
|
1077
|
+
|
|
1078
|
+
# Use streaming decompression (stream_reader)
|
|
1079
|
+
decompressor = zstandard.ZstdDecompressor()
|
|
1080
|
+
reader = decompressor.stream_reader(io.BytesIO(self._compressed_data))
|
|
1081
|
+
|
|
1082
|
+
chunks = []
|
|
1083
|
+
while True:
|
|
1084
|
+
chunk = reader.read(16384) # 16 KB at a time
|
|
1085
|
+
if not chunk:
|
|
1086
|
+
break
|
|
1087
|
+
chunks.append(chunk)
|
|
1088
|
+
|
|
1089
|
+
self._decompressed_data = b"".join(chunks)
|
|
1090
|
+
|
|
1091
|
+
# If in text mode, decode the bytes
|
|
1092
|
+
if self._text_mode:
|
|
1093
|
+
enc = self.encoding or 'UTF-8'
|
|
1094
|
+
err = self.errors or 'strict'
|
|
1095
|
+
self._decompressed_data = self._decompressed_data.decode(enc, err)
|
|
1096
|
+
|
|
1097
|
+
def write(self, data):
|
|
1098
|
+
"""
|
|
1099
|
+
Write data to the ZstdFile. In text mode, data is encoded;
|
|
1100
|
+
in binary mode, data is written as bytes. Each call to `write()`
|
|
1101
|
+
produces compressed chunks.
|
|
1102
|
+
"""
|
|
1103
|
+
if self._text_mode:
|
|
1104
|
+
# Encode data from str (Py3) or unicode (Py2) to bytes
|
|
1105
|
+
data = data.encode(self.encoding or 'UTF-8', self.errors or 'strict')
|
|
1106
|
+
|
|
1107
|
+
# Compress the chunk with the compressobj
|
|
1108
|
+
compressed_chunk = self._compressor.compress(data)
|
|
1109
|
+
if compressed_chunk:
|
|
1110
|
+
self.file.write(compressed_chunk)
|
|
1111
|
+
|
|
1112
|
+
def read(self, size=-1):
|
|
1113
|
+
"""
|
|
1114
|
+
Read from the decompressed data buffer.
|
|
1115
|
+
"""
|
|
1116
|
+
if size < 0:
|
|
1117
|
+
size = len(self._decompressed_data) - self._position
|
|
1118
|
+
data = self._decompressed_data[self._position:self._position + size]
|
|
1119
|
+
self._position += size
|
|
1120
|
+
return data
|
|
1121
|
+
|
|
1122
|
+
def seek(self, offset, whence=0):
|
|
1123
|
+
"""
|
|
1124
|
+
Adjust the current read position in the decompressed data buffer.
|
|
1125
|
+
"""
|
|
1126
|
+
if whence == 0: # absolute
|
|
1127
|
+
new_pos = offset
|
|
1128
|
+
elif whence == 1: # relative
|
|
1129
|
+
new_pos = self._position + offset
|
|
1130
|
+
elif whence == 2: # relative to end
|
|
1131
|
+
new_pos = len(self._decompressed_data) + offset
|
|
1132
|
+
else:
|
|
1133
|
+
raise ValueError("Invalid value for whence")
|
|
1134
|
+
|
|
1135
|
+
self._position = max(0, min(new_pos, len(self._decompressed_data)))
|
|
1136
|
+
|
|
1137
|
+
def tell(self):
|
|
1138
|
+
"""
|
|
1139
|
+
Return the current read position in the decompressed data buffer.
|
|
1140
|
+
"""
|
|
1141
|
+
return self._position
|
|
1142
|
+
|
|
1143
|
+
def flush(self):
|
|
1144
|
+
"""
|
|
1145
|
+
Flush the underlying file object. This doesn't force the Zstd
|
|
1146
|
+
compressor to flush partial data like zlib, but we can at least
|
|
1147
|
+
flush the OS buffer.
|
|
1148
|
+
"""
|
|
1149
|
+
self.file.flush()
|
|
1150
|
+
|
|
1151
|
+
def fileno(self):
|
|
1152
|
+
"""
|
|
1153
|
+
Return the file descriptor if available.
|
|
1154
|
+
"""
|
|
1155
|
+
if hasattr(self.file, 'fileno'):
|
|
1156
|
+
return self.file.fileno()
|
|
1157
|
+
raise OSError("The underlying file object does not support fileno()")
|
|
1158
|
+
|
|
1159
|
+
def isatty(self):
|
|
1160
|
+
"""
|
|
1161
|
+
Return whether the underlying file is a TTY.
|
|
1162
|
+
"""
|
|
1163
|
+
if hasattr(self.file, 'isatty'):
|
|
1164
|
+
return self.file.isatty()
|
|
1165
|
+
return False
|
|
1166
|
+
|
|
1167
|
+
def truncate(self, size=None):
|
|
1168
|
+
"""
|
|
1169
|
+
Truncate the underlying file if possible.
|
|
1170
|
+
"""
|
|
1171
|
+
if hasattr(self.file, 'truncate'):
|
|
1172
|
+
return self.file.truncate(size)
|
|
1173
|
+
raise OSError("The underlying file object does not support truncate()")
|
|
1174
|
+
|
|
1175
|
+
def close(self):
|
|
1176
|
+
"""
|
|
1177
|
+
If in write mode, finalize by flushing any remaining compressed data
|
|
1178
|
+
in the compressobj. Then close the file if we opened it.
|
|
1179
|
+
"""
|
|
1180
|
+
if any(x in self.mode for x in ('w', 'a', 'x')):
|
|
1181
|
+
# flush() returns any remaining compressed data in the compressobj
|
|
1182
|
+
final_chunk = self._compressor.flush()
|
|
1183
|
+
if final_chunk:
|
|
1184
|
+
self.file.write(final_chunk)
|
|
1185
|
+
|
|
1186
|
+
if self.file_path:
|
|
1187
|
+
self.file.close()
|
|
1188
|
+
|
|
1189
|
+
def __enter__(self):
|
|
1190
|
+
return self
|
|
1191
|
+
|
|
1192
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
1193
|
+
self.close()
|
|
1194
|
+
|
|
1195
|
+
|
|
1006
1196
|
'''
|
|
1007
1197
|
class BloscFile:
|
|
1008
1198
|
def __init__(self, file_path=None, fileobj=None, mode='rb', level=9, encoding=None, errors=None, newline=None):
|
|
@@ -1795,7 +1985,7 @@ def ReadFileHeaderDataBySizeWithContent(fp, listonly=False, uncompress=True, ski
|
|
|
1795
1985
|
else:
|
|
1796
1986
|
fcontents.seek(0, 0)
|
|
1797
1987
|
if(uncompress):
|
|
1798
|
-
fcontents =
|
|
1988
|
+
fcontents = UncompressArchiveFile(fcontents, formatspecs)
|
|
1799
1989
|
fcontentend = fp.tell()
|
|
1800
1990
|
if(re.findall("^\\+([0-9]+)", fseeknextfile)):
|
|
1801
1991
|
fseeknextasnum = int(fseeknextfile.replace("+", ""))
|
|
@@ -1908,7 +2098,7 @@ def ReadFileHeaderDataBySizeWithContentToArray(fp, listonly=False, contentasfile
|
|
|
1908
2098
|
else:
|
|
1909
2099
|
fcontents.seek(0, 0)
|
|
1910
2100
|
if(uncompress):
|
|
1911
|
-
fcontents =
|
|
2101
|
+
fcontents = UncompressArchiveFile(fcontents, formatspecs)
|
|
1912
2102
|
fcontents.seek(0, 0)
|
|
1913
2103
|
fccs = GetFileChecksum(
|
|
1914
2104
|
fcontents.read(), HeaderOut[-3].lower(), False, formatspecs)
|
|
@@ -2030,7 +2220,7 @@ def ReadFileHeaderDataBySizeWithContentToList(fp, listonly=False, uncompress=Tru
|
|
|
2030
2220
|
else:
|
|
2031
2221
|
fcontents.seek(0, 0)
|
|
2032
2222
|
if(uncompress):
|
|
2033
|
-
fcontents =
|
|
2223
|
+
fcontents = UncompressArchiveFile(fcontents, formatspecs)
|
|
2034
2224
|
fcontents.seek(0, 0)
|
|
2035
2225
|
fcontentend = fp.tell() - 1
|
|
2036
2226
|
if(re.findall("^\\+([0-9]+)", fseeknextfile)):
|
|
@@ -2306,7 +2496,7 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
|
|
|
2306
2496
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
2307
2497
|
fp = infile
|
|
2308
2498
|
fp.seek(0, 0)
|
|
2309
|
-
fp =
|
|
2499
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
2310
2500
|
checkcompressfile = CheckCompressionSubType(fp, formatspecs, True)
|
|
2311
2501
|
if(checkcompressfile != "catfile" and checkcompressfile != formatspecs['format_lower']):
|
|
2312
2502
|
return False
|
|
@@ -2320,13 +2510,13 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
|
|
|
2320
2510
|
else:
|
|
2321
2511
|
shutil.copyfileobj(sys.stdin, fp)
|
|
2322
2512
|
fp.seek(0, 0)
|
|
2323
|
-
fp =
|
|
2513
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
2324
2514
|
if(not fp):
|
|
2325
2515
|
return False
|
|
2326
2516
|
fp.seek(0, 0)
|
|
2327
2517
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
2328
2518
|
fp = download_file_from_internet_file(infile)
|
|
2329
|
-
fp =
|
|
2519
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
2330
2520
|
fp.seek(0, 0)
|
|
2331
2521
|
if(not fp):
|
|
2332
2522
|
return False
|
|
@@ -2369,7 +2559,7 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
|
|
|
2369
2559
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
2370
2560
|
fp = infile
|
|
2371
2561
|
fp.seek(0, 0)
|
|
2372
|
-
fp =
|
|
2562
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
2373
2563
|
checkcompressfile = CheckCompressionSubType(fp, formatspecs, True)
|
|
2374
2564
|
if(checkcompressfile != "catfile" and checkcompressfile != formatspecs['format_lower']):
|
|
2375
2565
|
return False
|
|
@@ -2383,13 +2573,13 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
|
|
|
2383
2573
|
else:
|
|
2384
2574
|
shutil.copyfileobj(sys.stdin, fp)
|
|
2385
2575
|
fp.seek(0, 0)
|
|
2386
|
-
fp =
|
|
2576
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
2387
2577
|
if(not fp):
|
|
2388
2578
|
return False
|
|
2389
2579
|
fp.seek(0, 0)
|
|
2390
2580
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
2391
2581
|
fp = download_file_from_internet_file(infile)
|
|
2392
|
-
fp =
|
|
2582
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
2393
2583
|
fp.seek(0, 0)
|
|
2394
2584
|
if(not fp):
|
|
2395
2585
|
return False
|
|
@@ -3201,27 +3391,27 @@ def CheckCompressionType(infile, formatspecs=__file_format_dict__, closefp=True)
|
|
|
3201
3391
|
prefp = catfp.read(2)
|
|
3202
3392
|
if(prefp == binascii.unhexlify("1f8b")):
|
|
3203
3393
|
filetype = "gzip"
|
|
3204
|
-
|
|
3394
|
+
elif(prefp == binascii.unhexlify("7801")):
|
|
3205
3395
|
filetype = "zlib"
|
|
3206
|
-
|
|
3396
|
+
elif(prefp == binascii.unhexlify("785e")):
|
|
3207
3397
|
filetype = "zlib"
|
|
3208
|
-
|
|
3398
|
+
elif(prefp == binascii.unhexlify("789c")):
|
|
3209
3399
|
filetype = "zlib"
|
|
3210
|
-
|
|
3400
|
+
elif(prefp == binascii.unhexlify("78da")):
|
|
3211
3401
|
filetype = "zlib"
|
|
3212
3402
|
catfp.seek(0, 0)
|
|
3213
3403
|
prefp = catfp.read(3)
|
|
3214
3404
|
if(prefp == binascii.unhexlify("425a68")):
|
|
3215
3405
|
filetype = "bzip2"
|
|
3216
|
-
|
|
3406
|
+
elif(prefp == binascii.unhexlify("5d0000")):
|
|
3217
3407
|
filetype = "lzma"
|
|
3218
3408
|
catfp.seek(0, 0)
|
|
3219
3409
|
prefp = catfp.read(4)
|
|
3220
3410
|
if(prefp == binascii.unhexlify("28b52ffd")):
|
|
3221
3411
|
filetype = "zstd"
|
|
3222
|
-
|
|
3412
|
+
elif(prefp == binascii.unhexlify("04224d18")):
|
|
3223
3413
|
filetype = "lz4"
|
|
3224
|
-
|
|
3414
|
+
elif(prefp == binascii.unhexlify("504B0304")):
|
|
3225
3415
|
filetype = "zipfile"
|
|
3226
3416
|
catfp.seek(0, 0)
|
|
3227
3417
|
prefp = catfp.read(5)
|
|
@@ -3231,13 +3421,13 @@ def CheckCompressionType(infile, formatspecs=__file_format_dict__, closefp=True)
|
|
|
3231
3421
|
prefp = catfp.read(6)
|
|
3232
3422
|
if(prefp == binascii.unhexlify("fd377a585a00")):
|
|
3233
3423
|
filetype = "lzma"
|
|
3234
|
-
|
|
3424
|
+
elif(prefp == binascii.unhexlify("377abcaf271c")):
|
|
3235
3425
|
filetype = "7zipfile"
|
|
3236
3426
|
catfp.seek(0, 0)
|
|
3237
3427
|
prefp = catfp.read(7)
|
|
3238
3428
|
if(prefp == binascii.unhexlify("526172211a0700")):
|
|
3239
3429
|
filetype = "rarfile"
|
|
3240
|
-
|
|
3430
|
+
elif(prefp == binascii.unhexlify("43617446696c65")):
|
|
3241
3431
|
filetype = "catfile"
|
|
3242
3432
|
catfp.seek(0, 0)
|
|
3243
3433
|
prefp = catfp.read(8)
|
|
@@ -3259,7 +3449,7 @@ def CheckCompressionType(infile, formatspecs=__file_format_dict__, closefp=True)
|
|
|
3259
3449
|
if(filetype == "gzip" or filetype == "bzip2" or filetype == "lzma" or filetype == "zstd" or filetype == "lz4" or filetype == "zlib"):
|
|
3260
3450
|
if(TarFileCheck(catfp)):
|
|
3261
3451
|
filetype = "tarfile"
|
|
3262
|
-
|
|
3452
|
+
elif(not filetype):
|
|
3263
3453
|
if(TarFileCheck(catfp)):
|
|
3264
3454
|
filetype = "tarfile"
|
|
3265
3455
|
elif(zipfile.is_zipfile(catfp)):
|
|
@@ -3300,22 +3490,24 @@ def GetCompressionMimeType(infile, formatspecs=__file_format_dict__):
|
|
|
3300
3490
|
compresscheck = CheckCompressionType(fp, formatspecs, False)
|
|
3301
3491
|
if(compresscheck == "gzip" or compresscheck == "gz"):
|
|
3302
3492
|
return archivefile_gzip_mimetype
|
|
3303
|
-
|
|
3493
|
+
elif(compresscheck == "zlib" or (compresscheck == "zz" or compresscheck == "zl" or compresscheck == "zlib")):
|
|
3304
3494
|
return archivefile_zlib_mimetype
|
|
3305
|
-
|
|
3495
|
+
elif(compresscheck == "bzip2" or compresscheck == "bz2"):
|
|
3306
3496
|
return archivefile_bzip2_mimetype
|
|
3307
|
-
|
|
3497
|
+
elif(compresscheck == "zstd" or compresscheck == "zstandard"):
|
|
3308
3498
|
return archivefile_zstandard_mimetype
|
|
3309
|
-
|
|
3499
|
+
elif(compresscheck == "lz4"):
|
|
3310
3500
|
return archivefile_lz4_mimetype
|
|
3311
|
-
|
|
3501
|
+
elif(compresscheck == "lzo" or compresscheck == "lzop"):
|
|
3312
3502
|
return archivefile_lzop_mimetype
|
|
3313
|
-
|
|
3503
|
+
elif(compresscheck == "lzma"):
|
|
3314
3504
|
return archivefile_lzma_mimetype
|
|
3315
|
-
|
|
3505
|
+
elif(compresscheck == "xz"):
|
|
3316
3506
|
return archivefile_xz_mimetype
|
|
3317
|
-
|
|
3507
|
+
elif(compresscheck == "catfile" or compresscheck == "cat" or compresscheck == formatspecs['format_lower']):
|
|
3318
3508
|
return archivefile_cat_mimetype
|
|
3509
|
+
else:
|
|
3510
|
+
return False
|
|
3319
3511
|
if(not compresscheck):
|
|
3320
3512
|
return False
|
|
3321
3513
|
return False
|
|
@@ -3331,7 +3523,7 @@ def UncompressArchiveFile(fp, formatspecs=__file_format_dict__):
|
|
|
3331
3523
|
elif(compresscheck == "bzip2" and compresscheck in compressionsupport):
|
|
3332
3524
|
catfp = bz2.BZ2File(fp)
|
|
3333
3525
|
elif(compresscheck == "zstd" and compresscheck in compressionsupport):
|
|
3334
|
-
catfp =
|
|
3526
|
+
catfp = ZstdFile(fileobj=fp, mode="rb")
|
|
3335
3527
|
elif(compresscheck == "lz4" and compresscheck in compressionsupport):
|
|
3336
3528
|
catfp = lz4.frame.LZ4FrameFile(fp, mode='rb')
|
|
3337
3529
|
elif((compresscheck == "lzo" or compresscheck == "lzop") and compresscheck in compressionsupport):
|
|
@@ -3365,27 +3557,28 @@ def UncompressFile(infile, formatspecs=__file_format_dict__, mode="rb"):
|
|
|
3365
3557
|
if(sys.version_info[0] == 2 and compresscheck):
|
|
3366
3558
|
if(mode == "rt"):
|
|
3367
3559
|
mode = "r"
|
|
3368
|
-
|
|
3560
|
+
elif(mode == "wt"):
|
|
3369
3561
|
mode = "w"
|
|
3370
3562
|
try:
|
|
3371
3563
|
if(compresscheck == "gzip" and compresscheck in compressionsupport):
|
|
3372
3564
|
filefp = gzip.open(infile, mode)
|
|
3373
|
-
|
|
3565
|
+
elif(compresscheck == "bzip2" and compresscheck in compressionsupport):
|
|
3374
3566
|
filefp = bz2.open(infile, mode)
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
if(compresscheck == "lz4" and compresscheck in compressionsupport):
|
|
3567
|
+
elif(compresscheck == "zstd" and compresscheck in compressionsupport):
|
|
3568
|
+
filefp = ZstdFile(infile, mode=mode)
|
|
3569
|
+
elif(compresscheck == "lz4" and compresscheck in compressionsupport):
|
|
3379
3570
|
filefp = lz4.frame.open(infile, mode)
|
|
3380
|
-
|
|
3571
|
+
elif((compresscheck == "lzo" or compresscheck == "lzop") and compresscheck in compressionsupport):
|
|
3381
3572
|
filefp = lzo.open(infile, mode)
|
|
3382
|
-
|
|
3573
|
+
elif((compresscheck == "lzma" or compresscheck == "xz") and compresscheck in compressionsupport):
|
|
3383
3574
|
filefp = lzma.open(infile, mode)
|
|
3384
|
-
|
|
3575
|
+
elif(compresscheck == "zlib" and compresscheck in compressionsupport):
|
|
3385
3576
|
filefp = ZlibFile(infile, mode=mode)
|
|
3386
|
-
|
|
3577
|
+
elif(compresscheck == "catfile" or compresscheck == formatspecs['format_lower']):
|
|
3387
3578
|
filefp = open(infile, mode)
|
|
3388
|
-
|
|
3579
|
+
elif(not compresscheck):
|
|
3580
|
+
filefp = open(infile, mode)
|
|
3581
|
+
else:
|
|
3389
3582
|
filefp = open(infile, mode)
|
|
3390
3583
|
except FileNotFoundError:
|
|
3391
3584
|
return False
|
|
@@ -3400,20 +3593,22 @@ def UncompressString(infile, formatspecs=__file_format_dict__):
|
|
|
3400
3593
|
compresscheck = CheckCompressionTypeFromString(infile, formatspecs, False)
|
|
3401
3594
|
if(compresscheck == "gzip" and compresscheck in compressionsupport):
|
|
3402
3595
|
fileuz = GzipDecompressData(infile)
|
|
3403
|
-
|
|
3596
|
+
elif(compresscheck == "bzip2" and compresscheck in compressionsupport):
|
|
3404
3597
|
fileuz = BzipDecompressData(infile)
|
|
3405
|
-
|
|
3598
|
+
elif(compresscheck == "zstd" and compresscheck in compressionsupport):
|
|
3406
3599
|
decompressor = zstandard.ZstdDecompressor()
|
|
3407
3600
|
fileuz = decompressor.decompress(infile)
|
|
3408
|
-
|
|
3601
|
+
elif(compresscheck == "lz4" and compresscheck in compressionsupport):
|
|
3409
3602
|
fileuz = lz4.frame.decompress(infile)
|
|
3410
|
-
|
|
3603
|
+
elif((compresscheck == "lzo" or compresscheck == "lzop") and compresscheck in compressionsupport):
|
|
3411
3604
|
fileuz = lzo.decompress(infile)
|
|
3412
|
-
|
|
3605
|
+
elif((compresscheck == "lzma" or compresscheck == "xz") and compresscheck in compressionsupport):
|
|
3413
3606
|
fileuz = lzma.decompress(infile)
|
|
3414
|
-
|
|
3607
|
+
elif(compresscheck == "zlib" and compresscheck in compressionsupport):
|
|
3415
3608
|
fileuz = zlib.decompress(infile)
|
|
3416
|
-
|
|
3609
|
+
elif(not compresscheck):
|
|
3610
|
+
fileuz = infile
|
|
3611
|
+
else:
|
|
3417
3612
|
fileuz = infile
|
|
3418
3613
|
if(hasattr(fileuz, 'decode')):
|
|
3419
3614
|
fileuz = fileuz.decode("UTF-8")
|
|
@@ -3446,20 +3641,22 @@ def UncompressBytes(infile, formatspecs=__file_format_dict__):
|
|
|
3446
3641
|
compresscheck = CheckCompressionTypeFromBytes(infile, formatspecs, False)
|
|
3447
3642
|
if(compresscheck == "gzip" and compresscheck in compressionsupport):
|
|
3448
3643
|
fileuz = GzipDecompressData(infile)
|
|
3449
|
-
|
|
3644
|
+
elif(compresscheck == "bzip2" and compresscheck in compressionsupport):
|
|
3450
3645
|
fileuz = BzipDecompressData(infile)
|
|
3451
|
-
|
|
3646
|
+
elif(compresscheck == "zstd" and compresscheck in compressionsupport):
|
|
3452
3647
|
decompressor = zstandard.ZstdDecompressor()
|
|
3453
3648
|
fileuz = decompressor.decompress(infile)
|
|
3454
|
-
|
|
3649
|
+
elif(compresscheck == "lz4" and compresscheck in compressionsupport):
|
|
3455
3650
|
fileuz = lz4.frame.decompress(infile)
|
|
3456
|
-
|
|
3651
|
+
elif((compresscheck == "lzo" or compresscheck == "lzop") and compresscheck in compressionsupport):
|
|
3457
3652
|
fileuz = lzo.decompress(infile)
|
|
3458
|
-
|
|
3653
|
+
elif((compresscheck == "lzma" or compresscheck == "xz") and compresscheck in compressionsupport):
|
|
3459
3654
|
fileuz = lzma.decompress(infile)
|
|
3460
|
-
|
|
3655
|
+
elif(compresscheck == "zlib" and compresscheck in compressionsupport):
|
|
3461
3656
|
fileuz = zlib.decompress(infile)
|
|
3462
|
-
|
|
3657
|
+
elif(not compresscheck):
|
|
3658
|
+
fileuz = infile
|
|
3659
|
+
else:
|
|
3463
3660
|
fileuz = infile
|
|
3464
3661
|
return fileuz
|
|
3465
3662
|
|
|
@@ -3538,7 +3735,7 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_dict__, closefp=Tr
|
|
|
3538
3735
|
if(py7zr_support and compresscheck == "7zipfile" and py7zr.is_7zfile(infile)):
|
|
3539
3736
|
return "7zipfile"
|
|
3540
3737
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
3541
|
-
catfp =
|
|
3738
|
+
catfp = UncompressArchiveFile(infile, formatspecs['format_lower'])
|
|
3542
3739
|
else:
|
|
3543
3740
|
try:
|
|
3544
3741
|
if(compresscheck == "gzip" and compresscheck in compressionsupport):
|
|
@@ -3548,7 +3745,7 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_dict__, closefp=Tr
|
|
|
3548
3745
|
elif(compresscheck == "lz4" and compresscheck in compressionsupport):
|
|
3549
3746
|
catfp = lz4.frame.open(infile, "rb")
|
|
3550
3747
|
elif(compresscheck == "zstd" and compresscheck in compressionsupport):
|
|
3551
|
-
catfp =
|
|
3748
|
+
catfp = ZstdFile(infile, mode="rb")
|
|
3552
3749
|
elif((compresscheck == "lzo" or compresscheck == "lzop") and compresscheck in compressionsupport):
|
|
3553
3750
|
catfp = lzo.open(infile, "rb")
|
|
3554
3751
|
elif((compresscheck == "lzma" or compresscheck == "xz") and compresscheck in compressionsupport):
|
|
@@ -3598,7 +3795,7 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
3598
3795
|
compressionlevel = int(compressionlevel)
|
|
3599
3796
|
catfp.write(GzipCompressData(
|
|
3600
3797
|
fp.read(), compresslevel=compressionlevel))
|
|
3601
|
-
|
|
3798
|
+
elif(compression == "bzip2" and compression in compressionsupport):
|
|
3602
3799
|
catfp = BytesIO()
|
|
3603
3800
|
if(compressionlevel is None):
|
|
3604
3801
|
compressionlevel = 9
|
|
@@ -3606,7 +3803,7 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
3606
3803
|
compressionlevel = int(compressionlevel)
|
|
3607
3804
|
catfp.write(BzipCompressData(
|
|
3608
3805
|
fp.read(), compresslevel=compressionlevel))
|
|
3609
|
-
|
|
3806
|
+
elif(compression == "lz4" and compression in compressionsupport):
|
|
3610
3807
|
catfp = BytesIO()
|
|
3611
3808
|
if(compressionlevel is None):
|
|
3612
3809
|
compressionlevel = 9
|
|
@@ -3614,14 +3811,14 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
3614
3811
|
compressionlevel = int(compressionlevel)
|
|
3615
3812
|
catfp.write(lz4.frame.compress(
|
|
3616
3813
|
fp.read(), compression_level=compressionlevel))
|
|
3617
|
-
|
|
3814
|
+
elif((compression == "lzo" or compression == "lzop") and compression in compressionsupport):
|
|
3618
3815
|
catfp = BytesIO()
|
|
3619
3816
|
if(compressionlevel is None):
|
|
3620
3817
|
compressionlevel = 9
|
|
3621
3818
|
else:
|
|
3622
3819
|
compressionlevel = int(compressionlevel)
|
|
3623
3820
|
catfp.write(lzo.compress(fp.read(), compresslevel=compressionlevel))
|
|
3624
|
-
|
|
3821
|
+
elif(compression == "zstd" and compression in compressionsupport):
|
|
3625
3822
|
catfp = BytesIO()
|
|
3626
3823
|
if(compressionlevel is None):
|
|
3627
3824
|
compressionlevel = 9
|
|
@@ -3629,7 +3826,7 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
3629
3826
|
compressionlevel = int(compressionlevel)
|
|
3630
3827
|
compressor = zstandard.ZstdCompressor(compressionlevel, threads=get_default_threads())
|
|
3631
3828
|
catfp.write(compressor.compress(fp.read()))
|
|
3632
|
-
|
|
3829
|
+
elif(compression == "lzma" and compression in compressionsupport):
|
|
3633
3830
|
catfp = BytesIO()
|
|
3634
3831
|
if(compressionlevel is None):
|
|
3635
3832
|
compressionlevel = 9
|
|
@@ -3639,7 +3836,7 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
3639
3836
|
catfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_ALONE, filters=[{"id": lzma.FILTER_LZMA1, "preset": compressionlevel}]))
|
|
3640
3837
|
except (NotImplementedError, lzma.LZMAError):
|
|
3641
3838
|
catfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_ALONE))
|
|
3642
|
-
|
|
3839
|
+
elif(compression == "xz" and compression in compressionsupport):
|
|
3643
3840
|
catfp = BytesIO()
|
|
3644
3841
|
if(compressionlevel is None):
|
|
3645
3842
|
compressionlevel = 9
|
|
@@ -3649,14 +3846,16 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
|
|
|
3649
3846
|
catfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_XZ, filters=[{"id": lzma.FILTER_LZMA2, "preset": compressionlevel}]))
|
|
3650
3847
|
except (NotImplementedError, lzma.LZMAError):
|
|
3651
3848
|
catfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_XZ))
|
|
3652
|
-
|
|
3849
|
+
elif(compression == "zlib" and compression in compressionsupport):
|
|
3653
3850
|
catfp = BytesIO()
|
|
3654
3851
|
if(compressionlevel is None):
|
|
3655
3852
|
compressionlevel = 9
|
|
3656
3853
|
else:
|
|
3657
3854
|
compressionlevel = int(compressionlevel)
|
|
3658
3855
|
catfp.write(zlib.compress(fp.read(), compressionlevel))
|
|
3659
|
-
|
|
3856
|
+
elif(compression == "auto" or compression is None):
|
|
3857
|
+
catfp = fp
|
|
3858
|
+
else:
|
|
3660
3859
|
catfp = fp
|
|
3661
3860
|
catfp.seek(0, 0)
|
|
3662
3861
|
return catfp
|
|
@@ -3687,8 +3886,7 @@ def CompressOpenFile(outfile, compressionenable=True, compressionlevel=None):
|
|
|
3687
3886
|
elif(fextname == ".bz2" and "bzip2" in compressionsupport):
|
|
3688
3887
|
outfp = bz2.open(outfile, mode, compressionlevel)
|
|
3689
3888
|
elif(fextname == ".zst" and "zstandard" in compressionsupport):
|
|
3690
|
-
outfp =
|
|
3691
|
-
outfile, mode, zstandard.ZstdCompressor(level=compressionlevel, threads=get_default_threads()))
|
|
3889
|
+
outfp = ZstdFile(outfile, mode=mode, level=compressionlevel)
|
|
3692
3890
|
elif(fextname == ".xz" and "xz" in compressionsupport):
|
|
3693
3891
|
try:
|
|
3694
3892
|
outfp = lzma.open(outfile, mode, format=lzma.FORMAT_XZ, filters=[{"id": lzma.FILTER_LZMA2, "preset": compressionlevel}])
|
|
@@ -5239,7 +5437,7 @@ def ArchiveFileSeekToFileNum(infile, seekto=0, listonly=False, contentasfile=Tru
|
|
|
5239
5437
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
5240
5438
|
catfp = infile
|
|
5241
5439
|
catfp.seek(0, 0)
|
|
5242
|
-
catfp =
|
|
5440
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5243
5441
|
checkcompressfile = CheckCompressionSubType(catfp, formatspecs, True)
|
|
5244
5442
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
5245
5443
|
return TarFileToArray(infile, seekto, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
|
|
@@ -5261,7 +5459,7 @@ def ArchiveFileSeekToFileNum(infile, seekto=0, listonly=False, contentasfile=Tru
|
|
|
5261
5459
|
else:
|
|
5262
5460
|
shutil.copyfileobj(sys.stdin, catfp)
|
|
5263
5461
|
catfp.seek(0, 0)
|
|
5264
|
-
catfp =
|
|
5462
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5265
5463
|
if(not catfp):
|
|
5266
5464
|
return False
|
|
5267
5465
|
catfp.seek(0, 0)
|
|
@@ -5269,14 +5467,14 @@ def ArchiveFileSeekToFileNum(infile, seekto=0, listonly=False, contentasfile=Tru
|
|
|
5269
5467
|
catfp = BytesIO()
|
|
5270
5468
|
catfp.write(infile)
|
|
5271
5469
|
catfp.seek(0, 0)
|
|
5272
|
-
catfp =
|
|
5470
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5273
5471
|
if(not catfp):
|
|
5274
5472
|
return False
|
|
5275
5473
|
catfp.seek(0, 0)
|
|
5276
5474
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5277
5475
|
catfp = download_file_from_internet_file(infile)
|
|
5278
5476
|
catfp.seek(0, 0)
|
|
5279
|
-
catfp =
|
|
5477
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5280
5478
|
if(not catfp):
|
|
5281
5479
|
return False
|
|
5282
5480
|
catfp.seek(0, 0)
|
|
@@ -5506,7 +5704,7 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, listonly=False, contentasfi
|
|
|
5506
5704
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
5507
5705
|
catfp = infile
|
|
5508
5706
|
catfp.seek(0, 0)
|
|
5509
|
-
catfp =
|
|
5707
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5510
5708
|
checkcompressfile = CheckCompressionSubType(catfp, formatspecs, True)
|
|
5511
5709
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
5512
5710
|
return TarFileToArray(infile, 0, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
|
|
@@ -5528,7 +5726,7 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, listonly=False, contentasfi
|
|
|
5528
5726
|
else:
|
|
5529
5727
|
shutil.copyfileobj(sys.stdin, catfp)
|
|
5530
5728
|
catfp.seek(0, 0)
|
|
5531
|
-
catfp =
|
|
5729
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5532
5730
|
if(not catfp):
|
|
5533
5731
|
return False
|
|
5534
5732
|
catfp.seek(0, 0)
|
|
@@ -5536,13 +5734,13 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, listonly=False, contentasfi
|
|
|
5536
5734
|
catfp = BytesIO()
|
|
5537
5735
|
catfp.write(infile)
|
|
5538
5736
|
catfp.seek(0, 0)
|
|
5539
|
-
catfp =
|
|
5737
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5540
5738
|
if(not catfp):
|
|
5541
5739
|
return False
|
|
5542
5740
|
catfp.seek(0, 0)
|
|
5543
5741
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5544
5742
|
catfp = download_file_from_internet_file(infile)
|
|
5545
|
-
catfp =
|
|
5743
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5546
5744
|
catfp.seek(0, 0)
|
|
5547
5745
|
if(not catfp):
|
|
5548
5746
|
return False
|
|
@@ -5786,7 +5984,7 @@ def ArchiveFileValidate(infile, formatspecs=__file_format_dict__, verbose=False,
|
|
|
5786
5984
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
5787
5985
|
catfp = infile
|
|
5788
5986
|
catfp.seek(0, 0)
|
|
5789
|
-
catfp =
|
|
5987
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5790
5988
|
checkcompressfile = CheckCompressionSubType(catfp, formatspecs, True)
|
|
5791
5989
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
5792
5990
|
return TarFileToArray(infile, 0, 0, False, True, False, formatspecs, returnfp)
|
|
@@ -5808,7 +6006,7 @@ def ArchiveFileValidate(infile, formatspecs=__file_format_dict__, verbose=False,
|
|
|
5808
6006
|
else:
|
|
5809
6007
|
shutil.copyfileobj(sys.stdin, catfp)
|
|
5810
6008
|
catfp.seek(0, 0)
|
|
5811
|
-
catfp =
|
|
6009
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5812
6010
|
if(not catfp):
|
|
5813
6011
|
return False
|
|
5814
6012
|
catfp.seek(0, 0)
|
|
@@ -5816,13 +6014,13 @@ def ArchiveFileValidate(infile, formatspecs=__file_format_dict__, verbose=False,
|
|
|
5816
6014
|
catfp = BytesIO()
|
|
5817
6015
|
catfp.write(infile)
|
|
5818
6016
|
catfp.seek(0, 0)
|
|
5819
|
-
catfp =
|
|
6017
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5820
6018
|
if(not catfp):
|
|
5821
6019
|
return False
|
|
5822
6020
|
catfp.seek(0, 0)
|
|
5823
6021
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
5824
6022
|
catfp = download_file_from_internet_file(infile)
|
|
5825
|
-
catfp =
|
|
6023
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
5826
6024
|
catfp.seek(0, 0)
|
|
5827
6025
|
if(not catfp):
|
|
5828
6026
|
return False
|
|
@@ -6073,7 +6271,7 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
|
|
|
6073
6271
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
6074
6272
|
catfp = infile
|
|
6075
6273
|
catfp.seek(0, 0)
|
|
6076
|
-
catfp =
|
|
6274
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
6077
6275
|
checkcompressfile = CheckCompressionSubType(catfp, formatspecs, True)
|
|
6078
6276
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
6079
6277
|
return TarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
|
|
@@ -6095,7 +6293,7 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
|
|
|
6095
6293
|
else:
|
|
6096
6294
|
shutil.copyfileobj(sys.stdin, catfp)
|
|
6097
6295
|
catfp.seek(0, 0)
|
|
6098
|
-
catfp =
|
|
6296
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
6099
6297
|
if(not catfp):
|
|
6100
6298
|
return False
|
|
6101
6299
|
catfp.seek(0, 0)
|
|
@@ -6103,13 +6301,13 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
|
|
|
6103
6301
|
catfp = BytesIO()
|
|
6104
6302
|
catfp.write(infile)
|
|
6105
6303
|
catfp.seek(0, 0)
|
|
6106
|
-
catfp =
|
|
6304
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
6107
6305
|
if(not catfp):
|
|
6108
6306
|
return False
|
|
6109
6307
|
catfp.seek(0, 0)
|
|
6110
6308
|
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", str(infile))):
|
|
6111
6309
|
catfp = download_file_from_internet_file(infile)
|
|
6112
|
-
catfp =
|
|
6310
|
+
catfp = UncompressArchiveFile(catfp, formatspecs)
|
|
6113
6311
|
catfp.seek(0, 0)
|
|
6114
6312
|
if(not catfp):
|
|
6115
6313
|
return False
|
|
@@ -6377,7 +6575,7 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
|
|
|
6377
6575
|
else:
|
|
6378
6576
|
catfcontents.seek(0, 0)
|
|
6379
6577
|
if(uncompress):
|
|
6380
|
-
catfcontents =
|
|
6578
|
+
catfcontents = UncompressArchiveFile(
|
|
6381
6579
|
catfcontents, formatspecs)
|
|
6382
6580
|
catfcontents.seek(0, 0)
|
|
6383
6581
|
catfccs = GetFileChecksum(
|
|
@@ -9444,7 +9642,7 @@ def download_file_from_internet_file(url, headers=geturls_headers_pycatfile_pyth
|
|
|
9444
9642
|
def download_file_from_internet_uncompress_file(url, headers=geturls_headers_pycatfile_python_alt, formatspecs=__file_format_dict__):
|
|
9445
9643
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
9446
9644
|
fp = download_file_from_internet_file(url)
|
|
9447
|
-
fp =
|
|
9645
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
9448
9646
|
fp.seek(0, 0)
|
|
9449
9647
|
if(not fp):
|
|
9450
9648
|
return False
|
|
@@ -9470,7 +9668,7 @@ def download_file_from_internet_string(url, headers=geturls_headers_pycatfile_py
|
|
|
9470
9668
|
def download_file_from_internet_uncompress_string(url, headers=geturls_headers_pycatfile_python_alt, formatspecs=__file_format_dict__):
|
|
9471
9669
|
formatspecs = FormatSpecsListToDict(formatspecs)
|
|
9472
9670
|
fp = download_file_from_internet_string(url)
|
|
9473
|
-
fp =
|
|
9671
|
+
fp = UncompressArchiveFile(fp, formatspecs)
|
|
9474
9672
|
fp.seek(0, 0)
|
|
9475
9673
|
if(not fp):
|
|
9476
9674
|
return False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|