@@ -3367,7 +3367,7 @@ def MakeEmptyCatFile(outfile, compression="auto", compresswholefile=True, compre
33673367 return MakeEmptyFile (outfile , compression , compresswholefile , compressionlevel , checksumtype , formatspecs , returnfp )
33683368
33693369
3370- def AppendFileHeaderWithContent (fp , filevalues = [], extradata = [], filecontent = "" , checksumtype = ["crc32" , "crc32" ], formatspecs = __file_format_dict__ ):
3370+ def AppendFileHeaderWithContent (fp , filevalues = [], extradata = [], jsondata = {}, filecontent = "" , checksumtype = ["crc32" , "crc32" ], formatspecs = __file_format_dict__ ):
33713371 if (not hasattr (fp , "write" )):
33723372 return False
33733373 if (isinstance (extradata , dict ) or IsNestedDictAlt (extradata )) and len (extradata ) > 0 :
@@ -3383,13 +3383,12 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
33833383 tmpoutlen = len (filevalues ) + len (extradata ) + 7
33843384 tmpoutlenhex = format (tmpoutlen , 'x' ).lower ()
33853385 tmpoutlist = filevalues
3386- fprejsoncontent = {'testing' : "test" }
3387- if (len (fprejsoncontent ) > 0 ):
3386+ if (len (jsondata ) > 0 ):
33883387 try :
3389- fjsoncontent = base64 .b64encode (json .dumps (fprejsoncontent , separators = (',' , ':' )).encode ("UTF-8" ))
3388+ fjsoncontent = base64 .b64encode (json .dumps (jsondata , separators = (',' , ':' )).encode ("UTF-8" ))
33903389 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
33913390 try :
3392- fjsoncontent = json .dumps (fprejsoncontent .decode ("UTF-8" ))
3391+ fjsoncontent = json .dumps (jsondata .decode ("UTF-8" ))
33933392 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
33943393 fjsoncontent = "" .encode ("UTF-8" )
33953394 else :
@@ -3449,7 +3448,7 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], filecontent="",
34493448 return fp
34503449
34513450
3452- 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 ):
3451+ 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 ):
34533452 if (not hasattr (fp , "write" )):
34543453 return False
34553454 advancedlist = formatspecs ['use_advanced_list' ]
@@ -3742,7 +3741,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
37423741 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
37433742 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
37443743 AppendFileHeaderWithContent (
3745- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
3744+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
37463745 if (numfiles > 0 ):
37473746 try :
37483747 fp .write (AppendNullBytes (
@@ -3753,7 +3752,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
37533752 return fp
37543753
37553754
3756- 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 ):
3755+ 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 ):
37573756 if (not hasattr (fp , "write" )):
37583757 return False
37593758 if (verbose ):
@@ -3811,7 +3810,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
38113810 fuid , funame , fgid , fgname , fid , finode , flinkcount , fdev , fdev_minor , fdev_major , fseeknextfile ]
38123811 fcontents .seek (0 , 0 )
38133812 AppendFileHeaderWithContent (
3814- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
3813+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
38153814 if (numfiles > 0 ):
38163815 try :
38173816 fp .write (AppendNullBytes (
@@ -4866,7 +4865,7 @@ def CheckSumSupportAlt(checkfor, guaranteed=True):
48664865 return False
48674866
48684867
4869- 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 ):
4868+ 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 ):
48704869 if (not hasattr (fp , "write" )):
48714870 return False
48724871 advancedlist = formatspecs ['use_advanced_list' ]
@@ -5159,7 +5158,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
51595158 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
51605159 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
51615160 AppendFileHeaderWithContent (
5162- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
5161+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
51635162 if (numfiles > 0 ):
51645163 try :
51655164 fp .write (AppendNullBytes (
@@ -5170,7 +5169,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
51705169 return fp
51715170
51725171
5173- 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 ):
5172+ 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 ):
51745173 if (not hasattr (fp , "write" )):
51755174 return False
51765175 if (verbose ):
@@ -5228,7 +5227,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
52285227 fuid , funame , fgid , fgname , fid , finode , flinkcount , fdev , fdev_minor , fdev_major , fseeknextfile ]
52295228 fcontents .seek (0 , 0 )
52305229 AppendFileHeaderWithContent (
5231- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
5230+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
52325231 if (numfiles > 0 ):
52335232 try :
52345233 fp .write (AppendNullBytes (
@@ -6283,7 +6282,7 @@ def CheckSumSupportAlt(checkfor, guaranteed=True):
62836282 return False
62846283
62856284
6286- def PackArchiveFile (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 ):
6285+ def PackArchiveFile (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 ):
62876286 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
62886287 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
62896288 get_in_ext = os .path .splitext (outfile )
@@ -6621,7 +6620,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
66216620 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
66226621 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
66236622 AppendFileHeaderWithContent (
6624- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
6623+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
66256624 fcontents .close ()
66266625 if (numfiles > 0 ):
66276626 try :
@@ -6670,7 +6669,7 @@ def PackArchiveFileFromDirList(infiles, outfile, dirlistfromtxt=False, fmttype="
66706669 return PackArchiveFile (infiles , outfile , dirlistfromtxt , fmttype , compression , compresswholefile , compressionlevel , compressionuselist , followlink , checksumtype , extradata , formatspecs , verbose , returnfp )
66716670
66726671
6673- def PackArchiveFileFromTarFile (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 ):
6672+ def PackArchiveFileFromTarFile (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 ):
66746673 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
66756674 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
66766675 get_in_ext = os .path .splitext (outfile )
@@ -6921,7 +6920,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
69216920 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
69226921 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
69236922 AppendFileHeaderWithContent (
6924- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
6923+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
69256924 fcontents .close ()
69266925 if (numfiles > 0 ):
69276926 try :
@@ -6966,7 +6965,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
69666965 return True
69676966
69686967
6969- def PackArchiveFileFromZipFile (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 ):
6968+ def PackArchiveFileFromZipFile (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 ):
69706969 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
69716970 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
69726971 get_in_ext = os .path .splitext (outfile )
@@ -7212,7 +7211,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
72127211 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
72137212 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
72147213 AppendFileHeaderWithContent (
7215- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
7214+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
72167215 fcontents .close ()
72177216 if (numfiles > 0 ):
72187217 try :
@@ -7258,11 +7257,11 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
72587257
72597258
72607259if (not rarfile_support ):
7261- def PackArchiveFileFromRarFile (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 ):
7260+ def PackArchiveFileFromRarFile (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 ):
72627261 return False
72637262
72647263if (rarfile_support ):
7265- def PackArchiveFileFromRarFile (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 ):
7264+ def PackArchiveFileFromRarFile (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 ):
72667265 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
72677266 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
72687267 get_in_ext = os .path .splitext (outfile )
@@ -7532,7 +7531,7 @@ def PackArchiveFileFromRarFile(infile, outfile, fmttype="auto", compression="aut
75327531 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
75337532 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
75347533 AppendFileHeaderWithContent (
7535- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
7534+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
75367535 fcontents .close ()
75377536 if (numfiles > 0 ):
75387537 try :
@@ -7582,7 +7581,7 @@ def PackArchiveFileFromSevenZipFile(infile, outfile, fmttype="auto", compression
75827581 return False
75837582
75847583if (py7zr_support ):
7585- def PackArchiveFileFromSevenZipFile (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 ):
7584+ def PackArchiveFileFromSevenZipFile (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 ):
75867585 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
75877586 (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr (outfile , "write" ))):
75887587 get_in_ext = os .path .splitext (outfile )
@@ -7785,7 +7784,7 @@ def PackArchiveFileFromSevenZipFile(infile, outfile, fmttype="auto", compression
77857784 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression ,
77867785 fcsize , fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , "+" + str (len (formatspecs ['format_delimiter' ]))]
77877786 AppendFileHeaderWithContent (
7788- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
7787+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
77897788 fcontents .close ()
77907789 if (numfiles > 0 ):
77917790 try :
@@ -9402,7 +9401,7 @@ def ArchiveFileArrayToArrayIndex(inarray, seekstart=0, seekend=0, listonly=False
94029401 return outarray
94039402
94049403
9405- def RePackArchiveFile (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 ):
9404+ def RePackArchiveFile (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 ):
94069405 if (isinstance (infile , dict )):
94079406 listarchivefiles = infile
94089407 else :
@@ -9526,6 +9525,8 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
95269525 listarchivefiles ['ffilelist' ][reallcfi ]['fextralist' ])
95279526 if (not followlink and len (extradata ) < 0 ):
95289527 extradata = listarchivefiles ['ffilelist' ][reallcfi ]['fextralist' ]
9528+ if (not followlink and len (jsondata ) <= 0 ):
9529+ jsondata = listarchivefiles ['ffilelist' ][reallcfi ]['jsondata' ]
95299530 fcontents = listarchivefiles ['ffilelist' ][reallcfi ]['fcontents' ]
95309531 if (not listarchivefiles ['ffilelist' ][reallcfi ]['fcontentasfile' ]):
95319532 fcontents = BytesIO (fcontents )
@@ -9606,6 +9607,8 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
96069607 flinkinfo ['fextrafields' ] = len (flinkinfo ['fextralist' ])
96079608 if (len (extradata ) < 0 ):
96089609 extradata = flinkinfo ['fextralist' ]
9610+ if (len (jsondata ) < 0 ):
9611+ extradata = flinkinfo ['jsondata' ]
96099612 fcontents = flinkinfo ['fcontents' ]
96109613 if (not flinkinfo ['fcontentasfile' ]):
96119614 fcontents = BytesIO (fcontents )
@@ -9631,7 +9634,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
96319634 tmpoutlist = [ftypehex , fencoding , fcencoding , fname , flinkname , fsize , fatime , fmtime , fctime , fbtime , fmode , fwinattributes , fcompression , fcsize ,
96329635 fuid , funame , fgid , fgname , fcurfid , fcurinode , flinkcount , fdev , fdev_minor , fdev_major , fseeknextfile ]
96339636 AppendFileHeaderWithContent (
9634- fp , tmpoutlist , extradata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
9637+ fp , tmpoutlist , extradata , jsondata , fcontents .read (), [checksumtype [1 ], checksumtype [2 ]], formatspecs )
96359638 fcontents .close ()
96369639 lcfi = lcfi + 1
96379640 reallcfi = reallcfi + 1
0 commit comments