@@ -2061,12 +2061,15 @@ def ReadFileHeaderDataWoSize(fp, delimiter=__file_format_dict__['format_delimite
20612061 return HeaderOut
20622062
20632063
2064- def ReadFileHeaderDataBySizeWithContent (fp , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
2064+ def ReadFileHeaderDataWithContent (fp , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
20652065 if (not hasattr (fp , "read" )):
20662066 return False
20672067 delimiter = formatspecs ['format_delimiter' ]
20682068 fheaderstart = fp .tell ()
2069- HeaderOut = ReadFileHeaderDataBySize (fp , delimiter )
2069+ if (formatspecs ['new_style' ]):
2070+ HeaderOut = ReadFileHeaderDataBySize (fp , delimiter )
2071+ else :
2072+ HeaderOut = ReadFileHeaderDataWoSize (fp , delimiter )
20702073 if (len (HeaderOut ) == 0 ):
20712074 return False
20722075 if (re .findall ("^[.|/]" , HeaderOut [3 ])):
@@ -2140,7 +2143,7 @@ def ReadFileHeaderDataBySizeWithContent(fp, listonly=False, uncompress=True, ski
21402143 return HeaderOut
21412144
21422145
2143- def ReadFileHeaderDataBySizeWithContentToArray (fp , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
2146+ def ReadFileHeaderDataWithContentToArray (fp , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
21442147 if (not hasattr (fp , "read" )):
21452148 return False
21462149 delimiter = formatspecs ['format_delimiter' ]
@@ -2265,7 +2268,7 @@ def ReadFileHeaderDataBySizeWithContentToArray(fp, listonly=False, contentasfile
22652268 return catlist
22662269
22672270
2268- def ReadFileHeaderDataBySizeWithContentToList (fp , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
2271+ def ReadFileHeaderDataWithContentToList (fp , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
22692272 if (not hasattr (fp , "read" )):
22702273 return False
22712274 delimiter = formatspecs ['format_delimiter' ]
@@ -2389,7 +2392,7 @@ def ReadFileHeaderDataBySizeWithContentToList(fp, listonly=False, uncompress=Tru
23892392 return catlist
23902393
23912394
2392- def ReadFileDataBySizeWithContent (fp , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
2395+ def ReadFileDataWithContent (fp , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
23932396 if (not hasattr (fp , "read" )):
23942397 return False
23952398 delimiter = formatspecs ['format_delimiter' ]
@@ -2435,7 +2438,7 @@ def ReadFileDataBySizeWithContent(fp, listonly=False, uncompress=True, skipcheck
24352438 countnum = 0
24362439 flist = []
24372440 while (countnum < fnumfiles ):
2438- HeaderOut = ReadFileHeaderDataBySizeWithContent (
2441+ HeaderOut = ReadFileHeaderDataWithContent (
24392442 fp , listonly , uncompress , skipchecksum , formatspecs )
24402443 if (len (HeaderOut ) == 0 ):
24412444 break
@@ -2444,7 +2447,7 @@ def ReadFileDataBySizeWithContent(fp, listonly=False, uncompress=True, skipcheck
24442447 return flist
24452448
24462449
2447- def ReadFileDataBySizeWithContentToArray (fp , seekstart = 0 , seekend = 0 , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
2450+ def ReadFileDataWithContentToArray (fp , seekstart = 0 , seekend = 0 , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
24482451 if (not hasattr (fp , "read" )):
24492452 return False
24502453 delimiter = formatspecs ['format_delimiter' ]
@@ -2569,7 +2572,7 @@ def ReadFileDataBySizeWithContentToArray(fp, seekstart=0, seekend=0, listonly=Fa
25692572 realidnum = 0
25702573 countnum = seekstart
25712574 while (countnum < seekend ):
2572- HeaderOut = ReadFileHeaderDataBySizeWithContentToArray (
2575+ HeaderOut = ReadFileHeaderDataWithContentToArray (
25732576 fp , listonly , contentasfile , uncompress , skipchecksum , formatspecs )
25742577 if (len (HeaderOut ) == 0 ):
25752578 break
@@ -2580,7 +2583,7 @@ def ReadFileDataBySizeWithContentToArray(fp, seekstart=0, seekend=0, listonly=Fa
25802583 return catlist
25812584
25822585
2583- def ReadFileDataBySizeWithContentToList (fp , seekstart = 0 , seekend = 0 , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
2586+ def ReadFileDataWithContentToList (fp , seekstart = 0 , seekend = 0 , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_dict__ ):
25842587 if (not hasattr (fp , "read" )):
25852588 return False
25862589 delimiter = formatspecs ['format_delimiter' ]
@@ -2649,8 +2652,12 @@ def ReadFileDataBySizeWithContentToList(fp, seekstart=0, seekend=0, listonly=Fal
26492652 il = 0
26502653 while (il < seekstart ):
26512654 prefhstart = fp .tell ()
2652- preheaderdata = ReadFileHeaderDataBySize (
2653- fp , formatspecs ['format_delimiter' ])
2655+ if (formatspecs ['new_style' ]):
2656+ preheaderdata = ReadFileHeaderDataBySize (
2657+ fp , formatspecs ['format_delimiter' ])
2658+ else :
2659+ preheaderdata = ReadFileHeaderDataWoSize (
2660+ fp , formatspecs ['format_delimiter' ])
26542661 if (len (preheaderdata ) == 0 ):
26552662 break
26562663 prefsize = int (preheaderdata [5 ], 16 )
@@ -2708,7 +2715,7 @@ def ReadFileDataBySizeWithContentToList(fp, seekstart=0, seekend=0, listonly=Fal
27082715 realidnum = 0
27092716 countnum = seekstart
27102717 while (countnum < seekend ):
2711- HeaderOut = ReadFileHeaderDataBySizeWithContentToList (
2718+ HeaderOut = ReadFileHeaderDataWithContentToList (
27122719 fp , listonly , uncompress , skipchecksum , formatspecs )
27132720 if (len (HeaderOut ) == 0 ):
27142721 break
@@ -2718,7 +2725,7 @@ def ReadFileDataBySizeWithContentToList(fp, seekstart=0, seekend=0, listonly=Fal
27182725 return catlist
27192726
27202727
2721- def ReadInFileBySizeWithContentToArray (infile , seekstart = 0 , seekend = 0 , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_multi_dict__ ):
2728+ def ReadInFileWithContentToArray (infile , seekstart = 0 , seekend = 0 , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_multi_dict__ ):
27222729 if (hasattr (infile , "read" ) or hasattr (infile , "write" )):
27232730 fp = infile
27242731 fp .seek (0 , 0 )
@@ -2775,6 +2782,8 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
27752782 else :
27762783 shutil .copyfileobj (sys .stdin , fp )
27772784 fp .seek (0 , 0 )
2785+ fp = UncompressArchiveFile (fp , formatspecs )
2786+ fp .seek (0 , 0 )
27782787 compresscheck = CheckCompressionType (fp , formatspecs , False )
27792788 if (IsNestedDict (formatspecs ) and compresscheck in formatspecs ):
27802789 formatspecs = formatspecs [compresscheck ]
@@ -2784,14 +2793,15 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
27842793 if (IsNestedDict (formatspecs ) and checkcompressfile in formatspecs ):
27852794 formatspecs = formatspecs [checkcompressfile ]
27862795 fp .seek (0 , 0 )
2787- fp = UncompressArchiveFile (fp , formatspecs )
27882796 if (not fp ):
27892797 return False
27902798 fp .seek (0 , 0 )
27912799 elif (isinstance (infile , bytes ) and sys .version_info [0 ] >= 3 ):
27922800 fp = BytesIO ()
27932801 fp .write (infile )
27942802 fp .seek (0 , 0 )
2803+ fp = UncompressArchiveFile (fp , formatspecs )
2804+ fp .seek (0 , 0 )
27952805 compresscheck = CheckCompressionType (fp , formatspecs , False )
27962806 if (IsNestedDict (formatspecs ) and compresscheck in formatspecs ):
27972807 formatspecs = formatspecs [compresscheck ]
@@ -2801,7 +2811,6 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
28012811 if (IsNestedDict (formatspecs ) and checkcompressfile in formatspecs ):
28022812 formatspecs = formatspecs [checkcompressfile ]
28032813 fp .seek (0 , 0 )
2804- fp = UncompressArchiveFile (fp , formatspecs )
28052814 if (not fp ):
28062815 return False
28072816 fp .seek (0 , 0 )
@@ -2883,10 +2892,10 @@ def ReadInFileBySizeWithContentToArray(infile, seekstart=0, seekend=0, listonly=
28832892 if (not compresscheck ):
28842893 return False
28852894 fp = UncompressFile (infile , formatspecs , "rb" )
2886- return ReadFileDataBySizeWithContentToArray (fp , seekstart , seekend , listonly , contentasfile , uncompress , skipchecksum , formatspecs )
2895+ return ReadFileDataWithContentToArray (fp , seekstart , seekend , listonly , contentasfile , uncompress , skipchecksum , formatspecs )
28872896
28882897
2889- def ReadInFileBySizeWithContentToList (infile , seekstart = 0 , seekend = 0 , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_multi_dict__ ):
2898+ def ReadInFileWithContentToList (infile , seekstart = 0 , seekend = 0 , listonly = False , uncompress = True , skipchecksum = False , formatspecs = __file_format_multi_dict__ ):
28902899 if (hasattr (infile , "read" ) or hasattr (infile , "write" )):
28912900 fp = infile
28922901 fp .seek (0 , 0 )
@@ -2943,6 +2952,8 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
29432952 else :
29442953 shutil .copyfileobj (sys .stdin , fp )
29452954 fp .seek (0 , 0 )
2955+ fp = UncompressArchiveFile (fp , formatspecs )
2956+ fp .seek (0 , 0 )
29462957 compresscheck = CheckCompressionType (fp , formatspecs , False )
29472958 if (IsNestedDict (formatspecs ) and compresscheck in formatspecs ):
29482959 formatspecs = formatspecs [compresscheck ]
@@ -2952,14 +2963,15 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
29522963 if (IsNestedDict (formatspecs ) and checkcompressfile in formatspecs ):
29532964 formatspecs = formatspecs [checkcompressfile ]
29542965 fp .seek (0 , 0 )
2955- fp = UncompressArchiveFile (fp , formatspecs )
29562966 if (not fp ):
29572967 return False
29582968 fp .seek (0 , 0 )
29592969 elif (isinstance (infile , bytes ) and sys .version_info [0 ] >= 3 ):
29602970 fp = BytesIO ()
29612971 fp .write (infile )
29622972 fp .seek (0 , 0 )
2973+ fp = UncompressArchiveFile (fp , formatspecs )
2974+ fp .seek (0 , 0 )
29632975 compresscheck = CheckCompressionType (fp , formatspecs , False )
29642976 if (IsNestedDict (formatspecs ) and compresscheck in formatspecs ):
29652977 formatspecs = formatspecs [compresscheck ]
@@ -2969,7 +2981,6 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
29692981 if (IsNestedDict (formatspecs ) and checkcompressfile in formatspecs ):
29702982 formatspecs = formatspecs [checkcompressfile ]
29712983 fp .seek (0 , 0 )
2972- fp = UncompressArchiveFile (fp , formatspecs )
29732984 if (not fp ):
29742985 return False
29752986 fp .seek (0 , 0 )
@@ -3051,7 +3062,7 @@ def ReadInFileBySizeWithContentToList(infile, seekstart=0, seekend=0, listonly=F
30513062 if (not compresscheck ):
30523063 return False
30533064 fp = UncompressFile (infile , formatspecs , "rb" )
3054- return ReadFileDataBySizeWithContentToList (fp , seekstart , seekend , listonly , uncompress , skipchecksum , formatspecs )
3065+ return ReadFileDataWithContentToList (fp , seekstart , seekend , listonly , uncompress , skipchecksum , formatspecs )
30553066
30563067
30573068def AppendNullByte (indata , delimiter = __file_format_dict__ ['format_delimiter' ]):
@@ -3629,7 +3640,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
36293640
36303641
36313642def AppendInFileWithContent (infile , fp , dirlistfromtxt = False , filevalues = [], extradata = [], followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], formatspecs = __file_format_dict__ , verbose = False ):
3632- inlist = ReadInFileBySizeWithContentToList (
3643+ inlist = ReadInFileWithContentToList (
36333644 infile , 0 , 0 , False , True , False , formatspecs )
36343645 return AppendListsWithContent (inlist , fp , dirlistfromtxt , filevalues , extradata , followlink , checksumtype , formatspecs , verbose )
36353646
@@ -3789,7 +3800,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
37893800
37903801
37913802def AppendInFileWithContentToOutFile (infile , outfile , dirlistfromtxt = False , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , filevalues = [], extradata = [], followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
3792- inlist = ReadInFileBySizeWithContentToList (
3803+ inlist = ReadInFileWithContentToList (
37933804 infile , 0 , 0 , False , True , False , formatspecs )
37943805 return AppendListsWithContentToOutFile (inlist , outfile , dirlistfromtxt , fmttype , compression , compresswholefile , compressionlevel , filevalues , extradata , followlink , checksumtype , formatspecs , verbose , returnfp )
37953806
0 commit comments