@@ -7920,9 +7920,20 @@ def PackCatFileFromInFile(infile, outfile, fmttype="auto", compression="auto", c
79207920 return False
79217921 return False
79227922
7923- # --- Add this helper (Py2/3 compatible) ---
7924- def CatFileArrayValidate (listarrayfiles , verbose = False ):
7925- # Top-level checks
7923+ def CatFileArrayValidate (infile , verbose = False ):
7924+ # ---------- Input handling ----------
7925+ if isinstance (infile , dict ):
7926+ listarrayfileslist = [infile ]
7927+ elif isinstance (infile , list ):
7928+ listarrayfileslist = infile
7929+ else :
7930+ if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
7931+ and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
7932+ infile = RemoveWindowsPath (infile )
7933+ listarrayfileslist = ArchiveFileToArray (
7934+ infile , fmttype , filestart , 0 , 0 ,
7935+ False , True , False , True , formatspecs , saltkey , seektoend , returnfp
7936+ )
79267937 if not isinstance (listarrayfiles , dict ):
79277938 if verbose : logging .warning ("listarrayfiles must be a dict, got %r" , type (listarrayfiles ))
79287939 return False
@@ -7934,53 +7945,53 @@ def CatFileArrayValidate(listarrayfiles, verbose=False):
79347945 if verbose : logging .warning ("ffilelist must be a list, got %r" , type (listarrayfiles ["ffilelist" ]))
79357946 return False
79367947
7937- # Per-entry required keys
7938- required = [
7939- "fname" , "fencoding" , "fheadersize" , "fsize" , "flinkname" ,
7940- "fatime" , "fmtime" , "fctime" , "fbtime" ,
7941- "fmode" , "fchmode" , "fuid" , "funame" , "fgid" , "fgname" ,
7942- "finode" , "flinkcount" , "fwinattributes" ,
7943- "fcompression" , "fcsize" ,
7944- "fdev" , "fminor" , "fmajor" ,
7945- "fseeknextfile" , "fextradata" , "fextrafields" ,
7946- "fcontents" , "fcontentasfile" , "fjsondata" , "ftype" ,
7947- ]
7948- ok = True
7949- for i , ent in enumerate (listarrayfiles ["ffilelist" ]):
7950- if not isinstance (ent , dict ):
7951- if verbose : logging .warning ("ffilelist[%d] must be a dict, got %r" , i , type (ent ))
7952- ok = False
7953- continue
7954- missing = [k for k in required if k not in ent ]
7955- if missing :
7956- if verbose : logging .warning ("ffilelist[%d] missing keys: %s" , i , ", " .join (missing ))
7957- ok = False
7958- continue
7959- # Light type/convert checks for numeric-ish fields
7960- intish = [
7961- "fheadersize" , "fsize" , "fatime" , "fmtime" , "fctime" , "fbtime" ,
7962- "fmode" , "fchmode" , "fuid" , "fgid" , "finode" ,
7963- "flinkcount" , "fwinattributes" , "fcsize" ,
7964- "fdev" , "fminor" , "fmajor" , "ftype" ,
7948+ for listarrayfiles in listarrayfileslist :
7949+ # Per-entry required keys
7950+ required = [
7951+ "fname" , "fencoding" , "fheadersize" , "fsize" , "flinkname" ,
7952+ "fatime" , "fmtime" , "fctime" , "fbtime" ,
7953+ "fmode" , "fchmode" , "fuid" , "funame" , "fgid" , "fgname" ,
7954+ "finode" , "flinkcount" , "fwinattributes" ,
7955+ "fcompression" , "fcsize" , "fdev" , "frdev" ,
7956+ "fseeknextfile" , "fextradata" , "fextrafields" ,
7957+ "fcontents" , "fcontentasfile" , "fjsondata" , "ftype" ,
79657958 ]
7966- for k in intish :
7967- try :
7968- int (ent [k ])
7969- except Exception :
7970- if verbose : logging .warning ("ffilelist[%d].%s expected int-convertible, got %r" , i , k , ent [k ])
7959+ ok = True
7960+ for i , ent in enumerate (listarrayfiles ["ffilelist" ]):
7961+ if not isinstance (ent , dict ):
7962+ if verbose : logging .warning ("ffilelist[%d] must be a dict, got %r" , i , type (ent ))
7963+ ok = False
7964+ continue
7965+ missing = [k for k in required if k not in ent ]
7966+ if missing :
7967+ if verbose : logging .warning ("ffilelist[%d] missing keys: %s" , i , ", " .join (missing ))
7968+ ok = False
7969+ continue
7970+ # Light type/convert checks for numeric-ish fields
7971+ intish = [
7972+ "fheadersize" , "fsize" , "fatime" , "fmtime" , "fctime" , "fbtime" ,
7973+ "fmode" , "fchmode" , "fuid" , "fgid" , "finode" ,
7974+ "flinkcount" , "fwinattributes" , "fcsize" ,
7975+ "fdev" , "frdev" , "ftype" ,
7976+ ]
7977+ for k in intish :
7978+ try :
7979+ int (ent [k ])
7980+ except Exception :
7981+ if verbose : logging .warning ("ffilelist[%d].%s expected int-convertible, got %r" , i , k , ent [k ])
7982+ ok = False
7983+ # Booleans/flags presence
7984+ if not isinstance (ent ["fcontentasfile" ], (bool , int )): # tolerate 0/1
7985+ if verbose : logging .warning ("ffilelist[%d].fcontentasfile should be bool-like, got %r" , i , ent ["fcontentasfile" ])
79717986 ok = False
7972- # Booleans/flags presence
7973- if not isinstance (ent ["fcontentasfile" ], (bool , int )): # tolerate 0/1
7974- if verbose : logging .warning ("ffilelist[%d].fcontentasfile should be bool-like, got %r" , i , ent ["fcontentasfile" ])
7975- ok = False
7976- # Arrays presence
7977- for arrk in ("fextradata" ,):
7978- if not isinstance (ent [arrk ], list ):
7979- if verbose : logging .warning ("ffilelist[%d].%s should be a list, got %r" , i , arrk , type (ent [arrk ]))
7987+ # Arrays presence
7988+ for arrk in ("fextradata" ,):
7989+ if not isinstance (ent [arrk ], list ):
7990+ if verbose : logging .warning ("ffilelist[%d].%s should be a list, got %r" , i , arrk , type (ent [arrk ]))
7991+ ok = False
7992+ if not isinstance (ent .get ("fjsondata" , {}), dict ):
7993+ if verbose : logging .warning ("ffilelist[%d].fjsondata should be a dict, got %r" , i , type (ent .get ("fjsondata" )))
79807994 ok = False
7981- if not isinstance (ent .get ("fjsondata" , {}), dict ):
7982- if verbose : logging .warning ("ffilelist[%d].fjsondata should be a dict, got %r" , i , type (ent .get ("fjsondata" )))
7983- ok = False
79847995 return ok
79857996
79867997def CatFileValidate (infile , fmttype = "auto" , filestart = 0 , formatspecs = __file_format_multi_dict__ , saltkey = None , seektoend = False , verbose = False , returnfp = False ):
0 commit comments