@@ -4086,30 +4086,30 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
40864086 fjstart = fp .tell ()
40874087 if (fjsontype == "json" ):
40884088 fjsoncontent = {}
4089- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4089+ fprejsoncontent = fp .read (fjsonsize )
40904090 if (fjsonsize > 0 ):
40914091 try :
4092- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4093- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4092+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4093+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
40944094 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
40954095 try :
40964096 fjsonrawcontent = fprejsoncontent
4097- fjsoncontent = json .loads (fprejsoncontent )
4097+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
40984098 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4099- fprejsoncontent = ""
4099+ fprejsoncontent = "" . encode ( "UTF-8" )
41004100 fjsonrawcontent = fprejsoncontent
41014101 fjsoncontent = {}
41024102 else :
4103- fprejsoncontent = ""
4103+ fprejsoncontent = "" . encode ( "UTF-8" )
41044104 fjsonrawcontent = fprejsoncontent
41054105 fjsoncontent = {}
41064106 elif (testyaml and fjsontype == "yaml" ):
41074107 fjsoncontent = {}
4108- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4108+ fprejsoncontent = fp .read (fjsonsize )
41094109 if (fjsonsize > 0 ):
41104110 try :
41114111 # try base64 → utf-8 → YAML
4112- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4112+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
41134113 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
41144114 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
41154115 try :
@@ -4118,20 +4118,20 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
41184118 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
41194119 except (UnicodeDecodeError , yaml .YAMLError ):
41204120 # final fallback: empty
4121- fprejsoncontent = ""
4121+ fprejsoncontent = "" . encode ( "UTF-8" )
41224122 fjsonrawcontent = fprejsoncontent
41234123 fjsoncontent = {}
41244124 else :
4125- fprejsoncontent = ""
4125+ fprejsoncontent = "" . encode ( "UTF-8" )
41264126 fjsonrawcontent = fprejsoncontent
41274127 fjsoncontent = {}
41284128 elif (not testyaml and fjsontype == "yaml" ):
41294129 fjsoncontent = {}
4130- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4131- fprejsoncontent = ""
4130+ fprejsoncontent = fp .read (fjsonsize )
4131+ fprejsoncontent = "" . encode ( "UTF-8" )
41324132 fjsonrawcontent = fprejsoncontent
41334133 elif (fjsontype == "list" ):
4134- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4134+ fprejsoncontent = fp .read (fjsonsize )
41354135 flisttmp = MkTempFile ()
41364136 flisttmp .write (fprejsoncontent .encode ())
41374137 flisttmp .seek (0 )
@@ -4304,30 +4304,30 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
43044304 fjstart = fp .tell ()
43054305 if (fjsontype == "json" ):
43064306 fjsoncontent = {}
4307- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4307+ fprejsoncontent = fp .read (fjsonsize )
43084308 if (fjsonsize > 0 ):
43094309 try :
4310- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4311- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4310+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4311+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
43124312 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
43134313 try :
43144314 fjsonrawcontent = fprejsoncontent
4315- fjsoncontent = json .loads (fprejsoncontent )
4315+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
43164316 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4317- fprejsoncontent = ""
4317+ fprejsoncontent = "" . encode ( "UTF-8" )
43184318 fjsonrawcontent = fprejsoncontent
43194319 fjsoncontent = {}
43204320 else :
4321- fprejsoncontent = ""
4321+ fprejsoncontent = "" . encode ( "UTF-8" )
43224322 fjsonrawcontent = fprejsoncontent
43234323 fjsoncontent = {}
43244324 elif (testyaml and fjsontype == "yaml" ):
43254325 fjsoncontent = {}
4326- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4326+ fprejsoncontent = fp .read (fjsonsize )
43274327 if (fjsonsize > 0 ):
43284328 try :
43294329 # try base64 → utf-8 → YAML
4330- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4330+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
43314331 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
43324332 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
43334333 try :
@@ -4336,20 +4336,20 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
43364336 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
43374337 except (UnicodeDecodeError , yaml .YAMLError ):
43384338 # final fallback: empty
4339- fprejsoncontent = ""
4339+ fprejsoncontent = "" . encode ( "UTF-8" )
43404340 fjsonrawcontent = fprejsoncontent
43414341 fjsoncontent = {}
43424342 else :
4343- fprejsoncontent = ""
4343+ fprejsoncontent = "" . encode ( "UTF-8" )
43444344 fjsonrawcontent = fprejsoncontent
43454345 fjsoncontent = {}
43464346 elif (not testyaml and fjsontype == "yaml" ):
43474347 fjsoncontent = {}
4348- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4349- fprejsoncontent = ""
4348+ fprejsoncontent = fp .read (fjsonsize )
4349+ fprejsoncontent = "" . encode ( "UTF-8" )
43504350 fjsonrawcontent = fprejsoncontent
43514351 elif (fjsontype == "list" ):
4352- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4352+ fprejsoncontent = fp .read (fjsonsize )
43534353 flisttmp = MkTempFile ()
43544354 flisttmp .write (fprejsoncontent .encode ())
43554355 flisttmp .seek (0 )
@@ -4523,30 +4523,30 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
45234523 fjstart = fp .tell ()
45244524 if (fjsontype == "json" ):
45254525 fjsoncontent = {}
4526- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4526+ fprejsoncontent = fp .read (fjsonsize )
45274527 if (fjsonsize > 0 ):
45284528 try :
4529- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4530- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4529+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4530+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
45314531 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
45324532 try :
45334533 fjsonrawcontent = fprejsoncontent
4534- fjsoncontent = json .loads (fprejsoncontent )
4534+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
45354535 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4536- fprejsoncontent = ""
4536+ fprejsoncontent = "" . encode ( "UTF-8" )
45374537 fjsonrawcontent = fprejsoncontent
45384538 fjsoncontent = {}
45394539 else :
4540- fprejsoncontent = ""
4540+ fprejsoncontent = "" . encode ( "UTF-8" )
45414541 fjsonrawcontent = fprejsoncontent
45424542 fjsoncontent = {}
45434543 elif (testyaml and fjsontype == "yaml" ):
45444544 fjsoncontent = {}
4545- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4545+ fprejsoncontent = fp .read (fjsonsize )
45464546 if (fjsonsize > 0 ):
45474547 try :
45484548 # try base64 → utf-8 → YAML
4549- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4549+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
45504550 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
45514551 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
45524552 try :
@@ -4555,20 +4555,20 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
45554555 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
45564556 except (UnicodeDecodeError , yaml .YAMLError ):
45574557 # final fallback: empty
4558- fprejsoncontent = ""
4558+ fprejsoncontent = "" . encode ( "UTF-8" )
45594559 fjsonrawcontent = fprejsoncontent
45604560 fjsoncontent = {}
45614561 else :
4562- fprejsoncontent = ""
4562+ fprejsoncontent = "" . encode ( "UTF-8" )
45634563 fjsonrawcontent = fprejsoncontent
45644564 fjsoncontent = {}
45654565 elif (not testyaml and fjsontype == "yaml" ):
45664566 fjsoncontent = {}
4567- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4568- fprejsoncontent = ""
4567+ fprejsoncontent = fp .read (fjsonsize )
4568+ fprejsoncontent = "" . encode ( "UTF-8" )
45694569 fjsonrawcontent = fprejsoncontent
45704570 elif (fjsontype == "list" ):
4571- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4571+ fprejsoncontent = fp .read (fjsonsize )
45724572 flisttmp = MkTempFile ()
45734573 flisttmp .write (fprejsoncontent .encode ())
45744574 flisttmp .seek (0 )
@@ -4800,30 +4800,30 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48004800 fjstart = fp .tell ()
48014801 if (fjsontype == "json" ):
48024802 fjsoncontent = {}
4803- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4803+ fprejsoncontent = fp .read (fjsonsize )
48044804 if (fjsonsize > 0 ):
48054805 try :
4806- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4807- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
4806+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
4807+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
48084808 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
48094809 try :
48104810 fjsonrawcontent = fprejsoncontent
4811- fjsoncontent = json .loads (fprejsoncontent )
4811+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
48124812 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
4813- fprejsoncontent = ""
4813+ fprejsoncontent = "" . encode ( "UTF-8" )
48144814 fjsonrawcontent = fprejsoncontent
48154815 fjsoncontent = {}
48164816 else :
4817- fprejsoncontent = ""
4817+ fprejsoncontent = "" . encode ( "UTF-8" )
48184818 fjsonrawcontent = fprejsoncontent
48194819 fjsoncontent = {}
48204820 elif (testyaml and fjsontype == "yaml" ):
48214821 fjsoncontent = {}
4822- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4822+ fprejsoncontent = fp .read (fjsonsize )
48234823 if (fjsonsize > 0 ):
48244824 try :
48254825 # try base64 → utf-8 → YAML
4826- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
4826+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
48274827 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
48284828 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
48294829 try :
@@ -4832,20 +4832,20 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
48324832 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
48334833 except (UnicodeDecodeError , yaml .YAMLError ):
48344834 # final fallback: empty
4835- fprejsoncontent = ""
4835+ fprejsoncontent = "" . encode ( "UTF-8" )
48364836 fjsonrawcontent = fprejsoncontent
48374837 fjsoncontent = {}
48384838 else :
4839- fprejsoncontent = ""
4839+ fprejsoncontent = "" . encode ( "UTF-8" )
48404840 fjsonrawcontent = fprejsoncontent
48414841 fjsoncontent = {}
48424842 elif (not testyaml and fjsontype == "yaml" ):
48434843 fjsoncontent = {}
4844- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4845- fprejsoncontent = ""
4844+ fprejsoncontent = fp .read (fjsonsize )
4845+ fprejsoncontent = "" . encode ( "UTF-8" )
48464846 fjsonrawcontent = fprejsoncontent
48474847 elif (fjsontype == "list" ):
4848- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
4848+ fprejsoncontent = fp .read (fjsonsize )
48494849 flisttmp = MkTempFile ()
48504850 flisttmp .write (fprejsoncontent .encode ())
48514851 flisttmp .seek (0 )
@@ -5063,30 +5063,30 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
50635063 fjstart = fp .tell ()
50645064 if (fjsontype == "json" ):
50655065 fjsoncontent = {}
5066- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5066+ fprejsoncontent = fp .read (fjsonsize )
50675067 if (fjsonsize > 0 ):
50685068 try :
5069- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
5070- fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent . encode ( "UTF-8" ) ).decode ("UTF-8" ))
5069+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
5070+ fjsoncontent = json .loads (base64 .b64decode (fprejsoncontent ).decode ("UTF-8" ))
50715071 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
50725072 try :
50735073 fjsonrawcontent = fprejsoncontent
5074- fjsoncontent = json .loads (fprejsoncontent )
5074+ fjsoncontent = json .loads (fprejsoncontent . decode ( "UTF-8" ) )
50755075 except (binascii .Error , json .decoder .JSONDecodeError , UnicodeDecodeError ):
5076- fprejsoncontent = ""
5076+ fprejsoncontent = "" . encode ( "UTF-8" )
50775077 fjsonrawcontent = fprejsoncontent
50785078 fjsoncontent = {}
50795079 else :
5080- fprejsoncontent = ""
5080+ fprejsoncontent = "" . encode ( "UTF-8" )
50815081 fjsonrawcontent = fprejsoncontent
50825082 fjsoncontent = {}
50835083 elif (testyaml and fjsontype == "yaml" ):
50845084 fjsoncontent = {}
5085- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5085+ fprejsoncontent = fp .read (fjsonsize )
50865086 if (fjsonsize > 0 ):
50875087 try :
50885088 # try base64 → utf-8 → YAML
5089- fjsonrawcontent = base64 .b64decode (fprejsoncontent . encode ( "UTF-8" )). decode ( "UTF-8" )
5089+ fjsonrawcontent = base64 .b64decode (fprejsoncontent )
50905090 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
50915091 except (binascii .Error , UnicodeDecodeError , yaml .YAMLError ):
50925092 try :
@@ -5095,20 +5095,20 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
50955095 fjsoncontent = yaml .safe_load (fjsonrawcontent ) or {}
50965096 except (UnicodeDecodeError , yaml .YAMLError ):
50975097 # final fallback: empty
5098- fprejsoncontent = ""
5098+ fprejsoncontent = "" . encode ( "UTF-8" )
50995099 fjsonrawcontent = fprejsoncontent
51005100 fjsoncontent = {}
51015101 else :
5102- fprejsoncontent = ""
5102+ fprejsoncontent = "" . encode ( "UTF-8" )
51035103 fjsonrawcontent = fprejsoncontent
51045104 fjsoncontent = {}
51055105 elif (not testyaml and fjsontype == "yaml" ):
51065106 fjsoncontent = {}
5107- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5108- fprejsoncontent = ""
5107+ fprejsoncontent = fp .read (fjsonsize )
5108+ fprejsoncontent = "" . encode ( "UTF-8" )
51095109 fjsonrawcontent = fprejsoncontent
51105110 elif (fjsontype == "list" ):
5111- fprejsoncontent = fp .read (fjsonsize ). decode ( "UTF-8" )
5111+ fprejsoncontent = fp .read (fjsonsize )
51125112 flisttmp = MkTempFile ()
51135113 flisttmp .write (fprejsoncontent .encode ())
51145114 flisttmp .seek (0 )
@@ -7916,7 +7916,6 @@ def PackNeoFileFromInFile(infile, outfile, fmttype="auto", compression="auto", c
79167916
79177917# --- Add this helper (Py2/3 compatible) ---
79187918def NeoFileArrayValidate (listarrayfiles , verbose = False ):
7919- import logging
79207919 # Top-level checks
79217920 if not isinstance (listarrayfiles , dict ):
79227921 if verbose : logging .warning ("listarrayfiles must be a dict, got %r" , type (listarrayfiles ))
@@ -7998,7 +7997,6 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
79987997 return False
79997998 if (not fp ):
80007999 return False
8001- fp .seek (filestart , 0 )
80028000 elif (infile == "-" ):
80038001 fp = MkTempFile ()
80048002 shutil .copyfileobj (PY_STDIN_BUF , fp , length = __filebuff_size__ )
@@ -8009,7 +8007,6 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80098007 formatspecs = formatspecs [checkcompressfile ]
80108008 if (not fp ):
80118009 return False
8012- fp .seek (filestart , 0 )
80138010 elif (isinstance (infile , bytes )):
80148011 fp = MkTempFile ()
80158012 fp .write (infile )
@@ -8020,17 +8017,14 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80208017 formatspecs = formatspecs [compresscheck ]
80218018 if (not fp ):
80228019 return False
8023- fp .seek (filestart , 0 )
80248020 elif (re .findall (__download_proto_support__ , infile ) and pywwwget ):
80258021 fp = download_file_from_internet_file (infile )
80268022 fp = UncompressFileAlt (fp , formatspecs , filestart )
80278023 compresscheck = CheckCompressionType (fp , formatspecs , 0 , False )
80288024 if (IsNestedDict (formatspecs ) and compresscheck in formatspecs ):
80298025 formatspecs = formatspecs [compresscheck ]
8030- fp .seek (filestart , 0 )
80318026 if (not fp ):
80328027 return False
8033- fp .seek (filestart , 0 )
80348028 else :
80358029 infile = RemoveWindowsPath (infile )
80368030 checkcompressfile = CheckCompressionSubType (infile , formatspecs , filestart , True )
@@ -8077,7 +8071,6 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80778071 return False
80788072 else :
80798073 formatspecs = formatspecs [compresschecking ]
8080- fp .seek (filestart , 0 )
80818074 inheaderver = str (int (formatspecs ['format_ver' ].replace ("." , "" )))
80828075 headeroffset = fp .tell ()
80838076 formstring = fp .read (formatspecs ['format_len' ] + len (inheaderver )).decode ("UTF-8" )
0 commit comments