Skip to content

Commit 15c99c4

Browse files
author
Kazuki Suzuki Przyborowski
committed
Update pycatfile.py
1 parent 2b646f3 commit 15c99c4

1 file changed

Lines changed: 36 additions & 12 deletions

File tree

pycatfile.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,7 +2736,9 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
27362736
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
27372737
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
27382738
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
2739-
elif(checkcompressfile != formatspecs['format_magic']):
2739+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
2740+
return False
2741+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
27402742
return False
27412743
if(not fp):
27422744
return False
@@ -2831,7 +2833,9 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
28312833
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
28322834
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
28332835
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
2834-
elif(checkcompressfile != formatspecs['format_magic']):
2836+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
2837+
return False
2838+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
28352839
return False
28362840
compresscheck = CheckCompressionType(infile, formatspecs, True)
28372841
if(not compresscheck):
@@ -2878,7 +2882,9 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
28782882
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
28792883
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
28802884
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
2881-
elif(checkcompressfile != formatspecs['format_magic']):
2885+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
2886+
return False
2887+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
28822888
return False
28832889
if(not fp):
28842890
return False
@@ -2973,7 +2979,9 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
29732979
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
29742980
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
29752981
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
2976-
elif(checkcompressfile != formatspecs['format_magic']):
2982+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
2983+
return False
2984+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
29772985
return False
29782986
compresscheck = CheckCompressionType(infile, formatspecs, True)
29792987
if(not compresscheck):
@@ -6142,7 +6150,9 @@ def ArchiveFileSeekToFileNum(infile, seekto=0, listonly=False, contentasfile=Tru
61426150
return RarFileToArray(infile, seekto, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
61436151
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
61446152
return SevenZipFileToArray(infile, seekto, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
6145-
elif(checkcompressfile != formatspecs['format_magic']):
6153+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
6154+
return False
6155+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
61466156
return False
61476157
if(not fp):
61486158
return False
@@ -6235,7 +6245,9 @@ def ArchiveFileSeekToFileNum(infile, seekto=0, listonly=False, contentasfile=Tru
62356245
return RarFileToArray(infile, seekto, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
62366246
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
62376247
return SevenZipFileToArray(infile, seekto, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
6238-
elif(checkcompressfile != formatspecs['format_magic']):
6248+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
6249+
return False
6250+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
62396251
return False
62406252
compresscheck = CheckCompressionType(infile, formatspecs, True)
62416253
if(not compresscheck):
@@ -6462,7 +6474,9 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, listonly=False, contentasfi
64626474
return RarFileToArray(infile, 0, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
64636475
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
64646476
return SevenZipFileToArray(infile, 0, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
6465-
elif(checkcompressfile != formatspecs['format_magic']):
6477+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
6478+
return False
6479+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
64666480
return False
64676481
if(not fp):
64686482
return False
@@ -6515,7 +6529,9 @@ def ArchiveFileSeekToFileName(infile, seekfile=None, listonly=False, contentasfi
65156529
return RarFileToArray(infile, 0, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
65166530
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
65176531
return SevenZipFileToArray(infile, 0, 0, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
6518-
elif(checkcompressfile != formatspecs['format_magic']):
6532+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
6533+
return False
6534+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
65196535
return False
65206536
compresscheck = CheckCompressionType(infile, formatspecs, True)
65216537
if(not compresscheck):
@@ -6750,7 +6766,9 @@ def ArchiveFileValidate(infile, formatspecs=__file_format_multi_dict__, verbose=
67506766
return RarFileToArray(infile, 0, 0, False, True, False, formatspecs, returnfp)
67516767
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
67526768
return SevenZipFileToArray(infile, 0, 0, False, True, False, formatspecs, returnfp)
6753-
elif(checkcompressfile != formatspecs['format_magic']):
6769+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
6770+
return False
6771+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
67546772
return False
67556773
if(not fp):
67566774
return False
@@ -6824,7 +6842,9 @@ def ArchiveFileValidate(infile, formatspecs=__file_format_multi_dict__, verbose=
68246842
return RarFileToArray(infile, 0, 0, False, True, False, formatspecs, returnfp)
68256843
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
68266844
return SevenZipFileToArray(infile, 0, 0, False, True, False, formatspecs, returnfp)
6827-
elif(checkcompressfile != formatspecs['format_magic']):
6845+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
6846+
return False
6847+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
68286848
return False
68296849
compresscheck = CheckCompressionType(infile, formatspecs, True)
68306850
if(not compresscheck):
@@ -7079,7 +7099,9 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
70797099
return RarFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
70807100
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
70817101
return SevenZipFileToArray(infile, seekstart, seekend, listonly, contentasfile, skipchecksum, formatspecs, returnfp)
7082-
elif(checkcompressfile != formatspecs['format_magic']):
7102+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
7103+
return False
7104+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
70837105
return False
70847106
if(not fp):
70857107
return False
@@ -7174,7 +7196,9 @@ def ArchiveFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentas
71747196
return RarFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
71757197
elif(py7zr_support and checkcompressfile == "7zipfile" and py7zr.is_7zfile(infile)):
71767198
return SevenZipFileToArray(infile, seekstart, seekend, listonly, skipchecksum, formatspecs, returnfp)
7177-
elif(checkcompressfile != formatspecs['format_magic']):
7199+
elif(IsSingleDict(formatspecs) and checkcompressfile != formatspecs['format_magic']):
7200+
return False
7201+
elif(IsNestedDict(formatspecs) and checkcompressfile not in formatspecs):
71787202
return False
71797203
compresscheck = CheckCompressionType(infile, formatspecs, True)
71807204
if(not compresscheck):

0 commit comments

Comments
 (0)