@@ -3379,7 +3379,7 @@ def MakeEmptyCatFile(outfile, compression="auto", compresswholefile=True, compre
33793379 return MakeEmptyFile (outfile , compression , compresswholefile , compressionlevel , checksumtype , formatspecs , returnfp )
33803380
33813381
3382- def AppendFileHeaderWithContent (fp , filevalues = [], extradata = [], filecontent = "" , checksumtype = ["crc32" , "crc32" ], formatspecs = __file_format_dict__ ):
3382+ def AppendFileHeaderWithContent (fp , filevalues = [], extradata = [], jsondata = {}, filecontent = "" , checksumtype = ["crc32" , "crc32" ], formatspecs = __file_format_dict__ ):
33833383 if (not hasattr (fp , "write" )):
33843384 return False
33853385 if (isinstance (extradata , dict ) or IsNestedDictAlt (extradata )) and len (extradata ) > 0 :
@@ -3395,13 +3395,12 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
33953395 tmpoutlen = len (filevalues ) + len (extradata ) + 7
33963396 tmpoutlenhex = format (tmpoutlen , 'x' ).lower ()
33973397 tmpoutlist = filevalues
3398- fprejsoncontent = {'testing' : "test" }
3399- if (len (fprejsoncontent ) > 0 ):
3398+ if (len (jsondata ) > 0 ):
34003399 try :
3401- fjsoncontent = base64 .b64encode (json .dumps (fprejsoncontent , separators = (',' , ':' )).encode ("UTF-8" ))
3400+ fjsoncontent = base64 .b64encode (json .dumps (jsondata , separators = (',' , ':' )).encode ("UTF-8" ))
34023401 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
34033402 try :
3404- fjsoncontent = json .dumps (fprejsoncontent .decode ("UTF-8" ))
3403+ fjsoncontent = json .dumps (jsondata .decode ("UTF-8" ))
34053404 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
34063405 fjsoncontent = "" .encode ("UTF-8" )
34073406 else :
@@ -3461,7 +3460,7 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
34613460 return fp
34623461
34633462
3464- def AppendFilesWithContent (infiles , fp , dirlistfromtxt = False , filevalues = [], extradata = [], compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], formatspecs = __file_format_dict__ , verbose = False ):
3463+ def AppendFilesWithContent (infiles , fp , dirlistfromtxt = False , filevalues = [], extradata = [], jsondata = {}, compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], formatspecs = __file_format_dict__ , verbose = False ):
34653464 if (not hasattr (fp , "write" )):
34663465 return False
34673466 advancedlist = formatspecs ['use_advanced_list' ]
@@ -3754,7 +3753,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
37543753 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
37553754 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
37563755 AppendFileHeaderWithContent (
3757- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
3756+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
37583757 if (numfiles > 0 ):
37593758 try :
37603759 fp .write (AppendNullBytes (
@@ -3765,7 +3764,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
37653764 return fp
37663765
37673766
3768- def AppendListsWithContent (inlist , fp , dirlistfromtxt = False , filevalues = [], extradata = [], compression = "auto" , compresswholefile = True , compressionlevel = None , followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], formatspecs = __file_format_dict__ , verbose = False ):
3767+ def AppendListsWithContent (inlist , fp , dirlistfromtxt = False , filevalues = [], extradata = [], jsondata = {}, compression = "auto" , compresswholefile = True , compressionlevel = None , followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], formatspecs = __file_format_dict__ , verbose = False ):
37693768 if (not hasattr (fp , "write" )):
37703769 return False
37713770 if (verbose ):
@@ -3823,7 +3822,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
38233822 fuid , funame , fgid , fgname , fid , finode , flinkcount , fdev , fdev_minor , fdev_major , fseeknextfile ]
38243823 fcontents .seek (0 , 0 )
38253824 AppendFileHeaderWithContent (
3826- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
3825+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
38273826 if (numfiles > 0 ):
38283827 try :
38293828 fp .write (AppendNullBytes (
@@ -4878,7 +4877,7 @@ def CheckSumSupportAlt(checkfor, guaranteed=True):
48784877 return False
48794878
48804879
4881- def PackCatFile (infiles , outfile , dirlistfromtxt = False , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], formatspecs = __file_format_multi_dict__ , verbose = False , returnfp = False ):
4880+ def PackCatFile (infiles , outfile , dirlistfromtxt = False , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , followlink = False , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], jsondata = {}, formatspecs = __file_format_multi_dict__ , verbose = False , returnfp = False ):
48824881 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
48834882 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
48844883 get_in_ext = os .path .splitext (outfile )
@@ -5265,7 +5264,7 @@ def PackCatFileFromDirList(infiles, outfile, dirlistfromtxt=False, fmttype="auto
52655264 return PackCatFile (infiles , outfile , dirlistfromtxt , fmttype , compression , compresswholefile , compressionlevel , compressionuselist , followlink , checksumtype , extradata , formatspecs , verbose , returnfp )
52665265
52675266
5268- def PackCatFileFromTarFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
5267+ def PackCatFileFromTarFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], jsondata = {}, formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
52695268 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
52705269 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
52715270 get_in_ext = os .path .splitext (outfile )
@@ -5516,7 +5515,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
55165515 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
55175516 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
55185517 AppendFileHeaderWithContent (
5519- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
5518+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
55205519 fcontents .close ()
55215520 if (numfiles > 0 ):
55225521 try :
@@ -5561,7 +5560,7 @@ def PackCatFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
55615560 return True
55625561
55635562
5564- def PackCatFileFromZipFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
5563+ def PackCatFileFromZipFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], jsondata = {}, formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
55655564 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
55665565 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
55675566 get_in_ext = os .path .splitext (outfile )
@@ -5807,7 +5806,7 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
58075806 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
58085807 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
58095808 AppendFileHeaderWithContent (
5810- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
5809+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
58115810 fcontents .close ()
58125811 if (numfiles > 0 ):
58135812 try :
@@ -5853,11 +5852,11 @@ def PackCatFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
58535852
58545853
58555854if (not rarfile_support ):
5856- def PackCatFileFromRarFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
5855+ def PackCatFileFromRarFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], jsondata = {}, formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
58575856 return False
58585857
58595858if (rarfile_support ):
5860- def PackCatFileFromRarFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
5859+ def PackCatFileFromRarFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], jsondata = {}, formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
58615860 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
58625861 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
58635862 get_in_ext = os .path .splitext (outfile )
@@ -6127,7 +6126,7 @@ def PackCatFileFromRarFile(infile, outfile, fmttype="auto", compression="auto",
61276126 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
61286127 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
61296128 AppendFileHeaderWithContent (
6130- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
6129+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
61316130 fcontents .close ()
61326131 if (numfiles > 0 ):
61336132 try :
@@ -6177,7 +6176,7 @@ def PackCatFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="au
61776176 return False
61786177
61796178if (py7zr_support ):
6180- def PackCatFileFromSevenZipFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
6179+ def PackCatFileFromSevenZipFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["crc32" , "crc32" , "crc32" ], extradata = [], jsondata = {}, formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
61816180 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
61826181 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
61836182 get_in_ext = os .path .splitext (outfile )
@@ -6380,7 +6379,7 @@ def PackCatFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="au
63806379 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
63816380 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
63826381 AppendFileHeaderWithContent (
6383- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
6382+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
63846383 fcontents .close ()
63856384 if (numfiles > 0 ):
63866385 try :
@@ -7997,7 +7996,7 @@ def CatFileArrayToArrayIndex(inarray, seekstart=0, seekend=0, listonly=False, un
79977996 return outarray
79987997
79997998
8000- def RePackCatFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , followlink = False , seekstart = 0 , seekend = 0 , checksumtype = ["crc32" , "crc32" , "crc32" ], skipchecksum = False , extradata = [], formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
7999+ def RePackCatFile (infile , outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , followlink = False , seekstart = 0 , seekend = 0 , checksumtype = ["crc32" , "crc32" , "crc32" ], skipchecksum = False , extradata = [], jsondata = {}, formatspecs = __file_format_dict__ , verbose = False , returnfp = False ):
80018000 if (isinstance (infile , dict )):
80028001 listarchivefiles = infile
80038002 else :
@@ -8119,8 +8118,10 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
81198118 if (len (listarchivefiles ['ffilelist' ][reallcfi ]['fextralist' ]) > listarchivefiles ['ffilelist' ][reallcfi ]['fextrafields' ] and len (listarchivefiles ['ffilelist' ][reallcfi ]['fextralist' ]) > 0 ):
81208119 listarchivefiles ['ffilelist' ][reallcfi ]['fextrafields' ] = len (
81218120 listarchivefiles ['ffilelist' ][reallcfi ]['fextralist' ])
8122- if (not followlink and len (extradata ) < 0 ):
8121+ if (not followlink and len (extradata ) <= 0 ):
81238122 extradata = listarchivefiles ['ffilelist' ][reallcfi ]['fextralist' ]
8123+ if (not followlink and len (jsondata ) <= 0 ):
8124+ jsondata = listarchivefiles ['ffilelist' ][reallcfi ]['jsondata' ]
81248125 fcontents = listarchivefiles ['ffilelist' ][reallcfi ]['fcontents' ]
81258126 if (not listarchivefiles ['ffilelist' ][reallcfi ]['fcontentasfile' ]):
81268127 fcontents = BytesIO (fcontents )
@@ -8201,6 +8202,8 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
82018202 flinkinfo ['fextrafields' ] = len (flinkinfo ['fextralist' ])
82028203 if (len (extradata ) < 0 ):
82038204 extradata = flinkinfo ['fextralist' ]
8205+ if (len (jsondata ) < 0 ):
8206+ extradata = flinkinfo ['jsondata' ]
82048207 fcontents = flinkinfo ['fcontents' ]
82058208 if (not flinkinfo ['fcontentasfile' ]):
82068209 fcontents = BytesIO (fcontents )
@@ -8226,7 +8229,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw
82268229 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression , fcsize ,
82278230 fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , fseeknextfile ]
82288231 AppendFileHeaderWithContent (
8229- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
8232+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
82308233 fcontents .close ()
82318234 lcfi = lcfi + 1
82328235 reallcfi = reallcfi + 1
0 commit comments