@@ -4092,30 +4092,30 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
40924092 fjstart = fp .tell ()
40934093 if (fjsontype == "json" ):
40944094 fjsoncontent = {}
4095- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4095+ fprejsoncontent = fp .read (fjsonsize )
40964096 if (fjsonsize > 0 ):
40974097 try :
4098- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4099- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4098+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4099+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
41004100 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
41014101 try :
41024102 fjsonrawcontent = fprejsoncontent
4103- fjsoncontent = json .loads (fprejsoncontent )
4103+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
41044104 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4105- fprejsoncontent = ""
4105+ fprejsoncontent = "" . encode ( "UTF-8" )
41064106 fjsonrawcontent = fprejsoncontent
41074107 fjsoncontent = {}
41084108 else :
4109- fprejsoncontent = ""
4109+ fprejsoncontent = "" . encode ( "UTF-8" )
41104110 fjsonrawcontent = fprejsoncontent
41114111 fjsoncontent = {}
41124112 elif (testyaml and fjsontype == "yaml" ):
41134113 fjsoncontent = {}
4114- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4114+ fprejsoncontent = fp .read (fjsonsize )
41154115 if (fjsonsize > 0 ):
41164116 try :
41174117 # try base64 → utf-8 → YAML
4118- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4118+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
41194119 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
41204120 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
41214121 try :
@@ -4124,20 +4124,20 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
41244124 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
41254125 except (UnicodeDecodeError , yaml .YAMLError ):
41264126 # final fallback: empty
4127- fprejsoncontent = ""
4127+ fprejsoncontent = "" . encode ( "UTF-8" )
41284128 fjsonrawcontent = fprejsoncontent
41294129 fjsoncontent = {}
41304130 else :
4131- fprejsoncontent = ""
4131+ fprejsoncontent = "" . encode ( "UTF-8" )
41324132 fjsonrawcontent = fprejsoncontent
41334133 fjsoncontent = {}
41344134 elif (not testyaml and fjsontype == "yaml" ):
41354135 fjsoncontent = {}
4136- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4137- fprejsoncontent = ""
4136+ fprejsoncontent = fp .read (fjsonsize )
4137+ fprejsoncontent = "" . encode ( "UTF-8" )
41384138 fjsonrawcontent = fprejsoncontent
41394139 elif (fjsontype == "list" ):
4140- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4140+ fprejsoncontent = fp .read (fjsonsize )
41414141 flisttmp = MkTempFile ()
41424142 flisttmp .write (fprejsoncontent .encode ())
41434143 flisttmp .seek (0 )
@@ -4310,30 +4310,30 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
43104310 fjstart = fp .tell ()
43114311 if (fjsontype == "json" ):
43124312 fjsoncontent = {}
4313- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4313+ fprejsoncontent = fp .read (fjsonsize )
43144314 if (fjsonsize > 0 ):
43154315 try :
4316- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4317- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4316+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4317+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
43184318 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
43194319 try :
43204320 fjsonrawcontent = fprejsoncontent
4321- fjsoncontent = json .loads (fprejsoncontent )
4321+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
43224322 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4323- fprejsoncontent = ""
4323+ fprejsoncontent = "" . encode ( "UTF-8" )
43244324 fjsonrawcontent = fprejsoncontent
43254325 fjsoncontent = {}
43264326 else :
4327- fprejsoncontent = ""
4327+ fprejsoncontent = "" . encode ( "UTF-8" )
43284328 fjsonrawcontent = fprejsoncontent
43294329 fjsoncontent = {}
43304330 elif (testyaml and fjsontype == "yaml" ):
43314331 fjsoncontent = {}
4332- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4332+ fprejsoncontent = fp .read (fjsonsize )
43334333 if (fjsonsize > 0 ):
43344334 try :
43354335 # try base64 → utf-8 → YAML
4336- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4336+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
43374337 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
43384338 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
43394339 try :
@@ -4342,20 +4342,20 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
43424342 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
43434343 except (UnicodeDecodeError , yaml .YAMLError ):
43444344 # final fallback: empty
4345- fprejsoncontent = ""
4345+ fprejsoncontent = "" . encode ( "UTF-8" )
43464346 fjsonrawcontent = fprejsoncontent
43474347 fjsoncontent = {}
43484348 else :
4349- fprejsoncontent = ""
4349+ fprejsoncontent = "" . encode ( "UTF-8" )
43504350 fjsonrawcontent = fprejsoncontent
43514351 fjsoncontent = {}
43524352 elif (not testyaml and fjsontype == "yaml" ):
43534353 fjsoncontent = {}
4354- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4355- fprejsoncontent = ""
4354+ fprejsoncontent = fp .read (fjsonsize )
4355+ fprejsoncontent = "" . encode ( "UTF-8" )
43564356 fjsonrawcontent = fprejsoncontent
43574357 elif (fjsontype == "list" ):
4358- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4358+ fprejsoncontent = fp .read (fjsonsize )
43594359 flisttmp = MkTempFile ()
43604360 flisttmp .write (fprejsoncontent .encode ())
43614361 flisttmp .seek (0 )
@@ -4529,30 +4529,30 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
45294529 fjstart = fp .tell ()
45304530 if (fjsontype == "json" ):
45314531 fjsoncontent = {}
4532- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4532+ fprejsoncontent = fp .read (fjsonsize )
45334533 if (fjsonsize > 0 ):
45344534 try :
4535- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4536- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4535+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4536+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
45374537 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
45384538 try :
45394539 fjsonrawcontent = fprejsoncontent
4540- fjsoncontent = json .loads (fprejsoncontent )
4540+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
45414541 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4542- fprejsoncontent = ""
4542+ fprejsoncontent = "" . encode ( "UTF-8" )
45434543 fjsonrawcontent = fprejsoncontent
45444544 fjsoncontent = {}
45454545 else :
4546- fprejsoncontent = ""
4546+ fprejsoncontent = "" . encode ( "UTF-8" )
45474547 fjsonrawcontent = fprejsoncontent
45484548 fjsoncontent = {}
45494549 elif (testyaml and fjsontype == "yaml" ):
45504550 fjsoncontent = {}
4551- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4551+ fprejsoncontent = fp .read (fjsonsize )
45524552 if (fjsonsize > 0 ):
45534553 try :
45544554 # try base64 → utf-8 → YAML
4555- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4555+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
45564556 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
45574557 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
45584558 try :
@@ -4561,20 +4561,20 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
45614561 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
45624562 except (UnicodeDecodeError , yaml .YAMLError ):
45634563 # final fallback: empty
4564- fprejsoncontent = ""
4564+ fprejsoncontent = "" . encode ( "UTF-8" )
45654565 fjsonrawcontent = fprejsoncontent
45664566 fjsoncontent = {}
45674567 else :
4568- fprejsoncontent = ""
4568+ fprejsoncontent = "" . encode ( "UTF-8" )
45694569 fjsonrawcontent = fprejsoncontent
45704570 fjsoncontent = {}
45714571 elif (not testyaml and fjsontype == "yaml" ):
45724572 fjsoncontent = {}
4573- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4574- fprejsoncontent = ""
4573+ fprejsoncontent = fp .read (fjsonsize )
4574+ fprejsoncontent = "" . encode ( "UTF-8" )
45754575 fjsonrawcontent = fprejsoncontent
45764576 elif (fjsontype == "list" ):
4577- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4577+ fprejsoncontent = fp .read (fjsonsize )
45784578 flisttmp = MkTempFile ()
45794579 flisttmp .write (fprejsoncontent .encode ())
45804580 flisttmp .seek (0 )
@@ -4806,30 +4806,30 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48064806 fjstart = fp .tell ()
48074807 if (fjsontype == "json" ):
48084808 fjsoncontent = {}
4809- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4809+ fprejsoncontent = fp .read (fjsonsize )
48104810 if (fjsonsize > 0 ):
48114811 try :
4812- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4813- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4812+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4813+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
48144814 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
48154815 try :
48164816 fjsonrawcontent = fprejsoncontent
4817- fjsoncontent = json .loads (fprejsoncontent )
4817+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
48184818 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4819- fprejsoncontent = ""
4819+ fprejsoncontent = "" . encode ( "UTF-8" )
48204820 fjsonrawcontent = fprejsoncontent
48214821 fjsoncontent = {}
48224822 else :
4823- fprejsoncontent = ""
4823+ fprejsoncontent = "" . encode ( "UTF-8" )
48244824 fjsonrawcontent = fprejsoncontent
48254825 fjsoncontent = {}
48264826 elif (testyaml and fjsontype == "yaml" ):
48274827 fjsoncontent = {}
4828- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4828+ fprejsoncontent = fp .read (fjsonsize )
48294829 if (fjsonsize > 0 ):
48304830 try :
48314831 # try base64 → utf-8 → YAML
4832- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4832+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
48334833 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
48344834 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
48354835 try :
@@ -4838,20 +4838,20 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48384838 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
48394839 except (UnicodeDecodeError , yaml .YAMLError ):
48404840 # final fallback: empty
4841- fprejsoncontent = ""
4841+ fprejsoncontent = "" . encode ( "UTF-8" )
48424842 fjsonrawcontent = fprejsoncontent
48434843 fjsoncontent = {}
48444844 else :
4845- fprejsoncontent = ""
4845+ fprejsoncontent = "" . encode ( "UTF-8" )
48464846 fjsonrawcontent = fprejsoncontent
48474847 fjsoncontent = {}
48484848 elif (not testyaml and fjsontype == "yaml" ):
48494849 fjsoncontent = {}
4850- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4851- fprejsoncontent = ""
4850+ fprejsoncontent = fp .read (fjsonsize )
4851+ fprejsoncontent = "" . encode ( "UTF-8" )
48524852 fjsonrawcontent = fprejsoncontent
48534853 elif (fjsontype == "list" ):
4854- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4854+ fprejsoncontent = fp .read (fjsonsize )
48554855 flisttmp = MkTempFile ()
48564856 flisttmp .write (fprejsoncontent .encode ())
48574857 flisttmp .seek (0 )
@@ -5069,30 +5069,30 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
50695069 fjstart = fp .tell ()
50705070 if (fjsontype == "json" ):
50715071 fjsoncontent = {}
5072- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5072+ fprejsoncontent = fp .read (fjsonsize )
50735073 if (fjsonsize > 0 ):
50745074 try :
5075- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
5076- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
5075+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
5076+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
50775077 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
50785078 try :
50795079 fjsonrawcontent = fprejsoncontent
5080- fjsoncontent = json .loads (fprejsoncontent )
5080+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
50815081 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
5082- fprejsoncontent = ""
5082+ fprejsoncontent = "" . encode ( "UTF-8" )
50835083 fjsonrawcontent = fprejsoncontent
50845084 fjsoncontent = {}
50855085 else :
5086- fprejsoncontent = ""
5086+ fprejsoncontent = "" . encode ( "UTF-8" )
50875087 fjsonrawcontent = fprejsoncontent
50885088 fjsoncontent = {}
50895089 elif (testyaml and fjsontype == "yaml" ):
50905090 fjsoncontent = {}
5091- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5091+ fprejsoncontent = fp .read (fjsonsize )
50925092 if (fjsonsize > 0 ):
50935093 try :
50945094 # try base64 → utf-8 → YAML
5095- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
5095+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
50965096 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
50975097 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
50985098 try :
@@ -5101,20 +5101,20 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
51015101 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
51025102 except (UnicodeDecodeError , yaml .YAMLError ):
51035103 # final fallback: empty
5104- fprejsoncontent = ""
5104+ fprejsoncontent = "" . encode ( "UTF-8" )
51055105 fjsonrawcontent = fprejsoncontent
51065106 fjsoncontent = {}
51075107 else :
5108- fprejsoncontent = ""
5108+ fprejsoncontent = "" . encode ( "UTF-8" )
51095109 fjsonrawcontent = fprejsoncontent
51105110 fjsoncontent = {}
51115111 elif (not testyaml and fjsontype == "yaml" ):
51125112 fjsoncontent = {}
5113- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5114- fprejsoncontent = ""
5113+ fprejsoncontent = fp .read (fjsonsize )
5114+ fprejsoncontent = "" . encode ( "UTF-8" )
51155115 fjsonrawcontent = fprejsoncontent
51165116 elif (fjsontype == "list" ):
5117- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5117+ fprejsoncontent = fp .read (fjsonsize )
51185118 flisttmp = MkTempFile ()
51195119 flisttmp .write (fprejsoncontent .encode ())
51205120 flisttmp .seek (0 )
@@ -7922,7 +7922,6 @@ def PackCatFileFromInFile(infile, outfile, fmttype="auto", compression="auto", c
79227922
79237923# --- Add this helper (Py2/3 compatible) ---
79247924def CatFileArrayValidate (listarrayfiles , verbose = False ):
7925- import logging
79267925 # Top-level checks
79277926 if not isinstance (listarrayfiles , dict ):
79287927 if verbose : logging .warning ("listarrayfiles must be a dict, got %r" , type (listarrayfiles ))
@@ -8004,7 +8003,6 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80048003 return False
80058004 if (not fp ):
80068005 return False
8007- fp .seek (filestart , 0 )
80088006 elif (infile == "-" ):
80098007 fp = MkTempFile ()
80108008 shutil .copyfileobj (PY_STDIN_BUF , fp , length = __filebuff_size__ )
@@ -8015,7 +8013,6 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80158013 formatspecs = formatspecs [checkcompressfile ]
80168014 if (not fp ):
80178015 return False
8018- fp .seek (filestart , 0 )
80198016 elif (isinstance (infile , bytes )):
80208017 fp = MkTempFile ()
80218018 fp .write (infile )
@@ -8026,17 +8023,14 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80268023 formatspecs = formatspecs [compresscheck ]
80278024 if (not fp ):
80288025 return False
8029- fp .seek (filestart , 0 )
80308026 elif (re .findall (__download_proto_support__ , infile ) and pywwwget ):
80318027 fp = download_file_from_internet_file (infile )
80328028 fp = UncompressFileAlt (fp , formatspecs , filestart )
80338029 compresscheck = CheckCompressionType (fp , formatspecs , 0 , False )
80348030 if (IsNestedDict (formatspecs ) and compresscheck in formatspecs ):
80358031 formatspecs = formatspecs [compresscheck ]
8036- fp .seek (filestart , 0 )
80378032 if (not fp ):
80388033 return False
8039- fp .seek (filestart , 0 )
80408034 else :
80418035 infile = RemoveWindowsPath (infile )
80428036 checkcompressfile = CheckCompressionSubType (infile , formatspecs , filestart , True )
@@ -8083,7 +8077,6 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80838077 return False
80848078 else :
80858079 formatspecs = formatspecs [compresschecking ]
8086- fp .seek (filestart , 0 )
80878080 inheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
80888081 headeroffset = fp .tell ()
80898082 formstring = fp .read (formatspecs ['format_len' ] + len (inheaderver )).decode ("UTF-8" )
0 commit comments