@@ -563,8 +563,8 @@ def resource_dir(package_name, filenames):
563563__use_json_name__ = os .path .join (filecfgpath , "neofile.json" )
564564if (__use_ini_file__ and __use_json_file__ ):
565565 __use_json_file__ = False
566- if ('PYARCHIVEFILE_CONFIG_FILE ' in os .environ and os .path .exists (os .environ ['PYARCHIVEFILE_CONFIG_FILE ' ]) and __use_env_file__ ):
567- scriptconf = os .environ ['PYARCHIVEFILE_CONFIG_FILE ' ]
566+ if ('PYNEOFILE_CONFIG_FILE ' in os .environ and os .path .exists (os .environ ['PYNEOFILE_CONFIG_FILE ' ]) and __use_env_file__ ):
567+ scriptconf = os .environ ['PYNEOFILE_CONFIG_FILE ' ]
568568else :
569569 prescriptpath = get_importing_script_path ()
570570 if (prescriptpath is not None ):
@@ -751,7 +751,7 @@ def _get(section_dict, key, default=None):
751751if __include_defaults__ :
752752 # Neo / Arc
753753 add_format (__file_format_multi_dict__ , "NeoFile" , "NeoFile" , ".neo" , "NeoFile" )
754- add_format (__file_format_multi_dict__ , "ArchiveFile " , "ArchiveFile " , ".arc" , "ArchiveFile " )
754+ add_format (__file_format_multi_dict__ , "NeoFile " , "NeoFile " , ".arc" , "NeoFile " )
755755
756756# Pick a default if current default key is not present
757757if __file_format_default__ not in __file_format_multi_dict__ :
@@ -1448,14 +1448,7 @@ def NormalizeRelativePath(inpath):
14481448 inpath = "file:///" + inpath [7 :]
14491449 dparsed = urlparse (inpath )
14501450 inpath = url2pathname (dparsed .path )
1451- inpath = RemoveWindowsPath (inpath )
1452- if os .path .isabs (inpath ):
1453- outpath = inpath
1454- else :
1455- if inpath .startswith ("./" ) or inpath .startswith ("../" ):
1456- outpath = inpath
1457- else :
1458- outpath = "./" + inpath
1451+ outpath = RemoveWindowsPath (inpath )
14591452 return outpath
14601453
14611454def PrependPath (base_dir , child_path ):
@@ -4042,10 +4035,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, contentasfile=False, uncom
40424035 HeaderOut = ReadFileHeaderDataBySize (fp , delimiter )
40434036 if (len (HeaderOut ) == 0 ):
40444037 return False
4045- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4046- fname = HeaderOut [5 ]
4047- else :
4048- fname = "./" + HeaderOut [5 ]
4038+ fname = HeaderOut [5 ]
40494039 fcs = HeaderOut [- 2 ].lower ()
40504040 fccs = HeaderOut [- 1 ].lower ()
40514041 fsize = int (HeaderOut [7 ], 16 )
@@ -4240,10 +4230,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
42404230 ftype = int (HeaderOut [2 ], 16 )
42414231 fencoding = HeaderOut [3 ]
42424232 fcencoding = HeaderOut [4 ]
4243- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4244- fname = HeaderOut [5 ]
4245- else :
4246- fname = "./" + HeaderOut [5 ]
4233+ fname = HeaderOut [5 ]
42474234 fbasedir = os .path .dirname (fname )
42484235 flinkname = HeaderOut [6 ]
42494236 fsize = int (HeaderOut [7 ], 16 )
@@ -4459,10 +4446,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
44594446 ftype = int (HeaderOut [2 ], 16 )
44604447 fencoding = HeaderOut [3 ]
44614448 fcencoding = HeaderOut [4 ]
4462- if (re .findall ("^[.|/]" , HeaderOut [5 ])):
4463- fname = HeaderOut [5 ]
4464- else :
4465- fname = "./" + HeaderOut [5 ]
4449+ fname = HeaderOut [5 ]
44664450 fbasedir = os .path .dirname (fname )
44674451 flinkname = HeaderOut [6 ]
44684452 fsize = int (HeaderOut [7 ], 16 )
@@ -4919,10 +4903,7 @@ def ReadFileDataWithContentToArray(fp, filestart=0, seekstart=0, seekend=0, list
49194903 if (len (preheaderdata ) == 0 ):
49204904 break
49214905 prefsize = int (preheaderdata [5 ], 16 )
4922- if (re .findall ("^[.|/]" , preheaderdata [5 ])):
4923- prefname = preheaderdata [5 ]
4924- else :
4925- prefname = "./" + preheaderdata [5 ]
4906+ prefname = preheaderdata [5 ]
49264907 prefseeknextfile = preheaderdata [26 ]
49274908 prefjsonlen = int (preheaderdata [28 ], 16 )
49284909 prefjsonsize = int (preheaderdata [29 ], 16 )
@@ -5181,10 +5162,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
51815162 if (len (preheaderdata ) == 0 ):
51825163 break
51835164 prefsize = int (preheaderdata [5 ], 16 )
5184- if (re .findall ("^[.|/]" , preheaderdata [5 ])):
5185- prefname = preheaderdata [5 ]
5186- else :
5187- prefname = "./" + preheaderdata [5 ]
5165+ prefname = preheaderdata [5 ]
51885166 prefcompression = preheaderdata [14 ]
51895167 prefcsize = int (preheaderdata [15 ], 16 )
51905168 prefseeknextfile = preheaderdata [26 ]
@@ -5843,10 +5821,7 @@ def AppendFilesWithContentToList(infiles, dirlistfromtxt=False, extradata=[], js
58435821 tmpoutlist = []
58445822 for curfname in GetDirList :
58455823 fencoding = "UTF-8"
5846- if (re .findall ("^[.|/]" , curfname )):
5847- fname = curfname
5848- else :
5849- fname = "./" + curfname
5824+ fname = curfname
58505825 if (not os .path .exists (fname )):
58515826 return False
58525827 if (verbose ):
@@ -6203,10 +6178,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
62036178 tmpoutlist = []
62046179 for member in sorted (tarfp .getmembers (), key = lambda x : x .name ):
62056180 fencoding = "UTF-8"
6206- if (re .findall ("^[.|/]" , member .name )):
6207- fname = member .name
6208- else :
6209- fname = "./" + member .name
6181+ fname = member .name
62106182 if (verbose ):
62116183 VerbosePrintOut (fname )
62126184 fpremode = member .mode
@@ -6410,10 +6382,7 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
64106382 tmpoutlist = []
64116383 for member in sorted (zipfp .infolist (), key = lambda x : x .filename ):
64126384 fencoding = "UTF-8"
6413- if (re .findall ("^[.|/]" , member .filename )):
6414- fname = member .filename
6415- else :
6416- fname = "./" + member .filename
6385+ fname = member .filename
64176386 zipinfo = zipfp .getinfo (member .filename )
64186387 if (verbose ):
64196388 VerbosePrintOut (fname )
@@ -6664,10 +6633,7 @@ def AppendFilesWithContentFromRarFileToList(infile, extradata=[], jsondata={}, c
66646633 is_unix = False
66656634 is_windows = False
66666635 fencoding = "UTF-8"
6667- if (re .findall ("^[.|/]" , member .filename )):
6668- fname = member .filename
6669- else :
6670- fname = "./" + member .filename
6636+ fname = member .filename
66716637 rarinfo = rarfp .getinfo (member .filename )
66726638 if (verbose ):
66736639 VerbosePrintOut (fname )
@@ -6932,10 +6898,7 @@ def AppendFilesWithContentFromSevenZipFileToList(infile, extradata=[], jsondata=
69326898 tmpoutlist = []
69336899 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
69346900 fencoding = "UTF-8"
6935- if (re .findall ("^[.|/]" , member .filename )):
6936- fname = member .filename
6937- else :
6938- fname = "./" + member .filename
6901+ fname = member .filename
69396902 if (verbose ):
69406903 VerbosePrintOut (fname )
69416904 if (not member .is_directory ):
@@ -7123,10 +7086,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, extradata=[], jsond
71237086 ftype = format (curfname [0 ], 'x' ).lower ()
71247087 fencoding = curfname [1 ]
71257088 fcencoding = curfname [2 ]
7126- if (re .findall ("^[.|/]" , curfname [3 ])):
7127- fname = curfname [3 ]
7128- else :
7129- fname = "./" + curfname [3 ]
7089+ fname = curfname [3 ]
71307090 if (not os .path .exists (fname )):
71317091 return False
71327092 fbasedir = os .path .dirname (fname )
@@ -7924,7 +7884,7 @@ def NeoFileArrayValidate(infile, fmttype="auto", filestart=0, formatspecs=__file
79247884 if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
79257885 and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
79267886 infile = RemoveWindowsPath (infile )
7927- listarrayfileslist = ArchiveFileToArray (
7887+ listarrayfileslist = NeoFileToArray (
79287888 infile , fmttype , filestart , 0 , 0 ,
79297889 False , True , False , True , formatspecs , saltkey , seektoend , returnfp
79307890 )
@@ -7998,7 +7958,7 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
79987958 if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
79997959 and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
80007960 infile = RemoveWindowsPath (infile )
8001- listarrayfileslist = ArchiveFileToArray (
7961+ listarrayfileslist = NeoFileToArray (
80027962 infile , fmttype , filestart , 0 , 0 ,
80037963 False , True , False , True , formatspecs , saltkey , seektoend , returnfp
80047964 )
@@ -8061,10 +8021,7 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
80618021 inheaderdata = cur_entry ['frawheader' ]
80628022 if (len (inheaderdata ) == 0 ):
80638023 break
8064- if (re .findall ("^[.|/]" , inheaderdata [5 ])):
8065- outfname = inheaderdata [5 ]
8066- else :
8067- outfname = "./" + inheaderdata [5 ]
8024+ outfname = inheaderdata [5 ]
80688025 outfbasedir = os .path .dirname (outfname )
80698026 outfsize = int (inheaderdata [7 ], 16 )
80708027 outfcompression = inheaderdata [17 ]
@@ -8123,6 +8080,7 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
81238080 pyhascontents = False
81248081 if (outfsize > 0 ):
81258082 outfcontents = cur_entry ['fcontents' ]
8083+ outfcontents .seek (0 , 0 )
81268084 infccs = GetFileChecksum (outfcontents , inheaderdata [- 3 ].lower (), False , formatspecs , saltkey )
81278085 pyhascontents = True
81288086 if (CheckChecksums (outfccs , infccs )):
@@ -8148,6 +8106,7 @@ def NeoFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form
81488106 fp .close ()
81498107 return False
81508108
8109+
81518110def NeoFileValidateFile (infile , fmttype = "auto" , filestart = 0 , formatspecs = __file_format_multi_dict__ , saltkey = None , seektoend = False , verbose = False , returnfp = False ):
81528111 return NeoFileValidate (infile , fmttype , filestart , formatspecs , saltkey , seektoend , verbose , returnfp )
81538112
@@ -8571,10 +8530,7 @@ def RePackNeoFile(infile, outfile, fmttype="auto", compression="auto", compressw
85718530
85728531 # path
85738532 fname_field = cur_entry ['fname' ]
8574- if re .findall (r"^[.|/]" , fname_field ):
8575- fname = fname_field
8576- else :
8577- fname = "./" + fname_field
8533+ fname = fname_field
85788534
85798535 if verbose :
85808536 VerbosePrintOut (fname )
@@ -9675,10 +9631,7 @@ def SevenZipFileListFiles(infile, verbose=False, returnfp=False):
96759631 if (sztestalt ):
96769632 VerbosePrintOut ("Bad file found!" )
96779633 for member in sorted (szpfp .list (), key = lambda x : x .filename ):
9678- if (re .findall ("^[.|/]" , member .filename )):
9679- fname = member .filename
9680- else :
9681- fname = "./" + member .filename
9634+ fname = member .filename
96829635 if (not member .is_directory ):
96839636 fpremode = int (stat .S_IFREG | 0x1b6 )
96849637 elif (member .is_directory ):
@@ -9783,7 +9736,7 @@ def InFileListFiles(infile, fmttype="auto", filestart=0, seekstart=0, seekend=0,
97839736 elif (py7zr_support and checkcompressfile == "7zipfile" and py7zr .is_7zfile (infile )):
97849737 return SevenZipFileListFiles (infile , verbose , returnfp )
97859738 elif (checkcompressfile == formatspecs ['format_magic' ]):
9786- return ArchiveFileListFiles (infile , fmttype , filestart , seekstart , seekend , skipchecksum , formatspecs , saltkey , seektoend , verbose , newstyle , returnfp )
9739+ return NeoFileListFiles (infile , fmttype , filestart , seekstart , seekend , skipchecksum , formatspecs , saltkey , seektoend , verbose , newstyle , returnfp )
97879740 else :
97889741 return False
97899742 return False
0 commit comments