Skip to content

Commit df9f39b

Browse files
authored
Add files via upload
1 parent 8347000 commit df9f39b

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

pyfoxfile.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def get_default_threads():
266266

267267

268268
__use_pysftp__ = False
269+
__upload_proto_support__ = "^(ftp|ftps|sftp):\\/\\/"
270+
__download_proto_support__ = "^(http|https|ftp|ftps|sftp):\\/\\/"
269271
if(not havepysftp):
270272
__use_pysftp__ = False
271273
__use_http_lib__ = "httpx"
@@ -2996,7 +2998,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
29962998
if(not fp):
29972999
return False
29983000
fp.seek(0, 0)
2999-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
3001+
elif(re.findall(__download_proto_support__, infile)):
30003002
fp = download_file_from_internet_file(infile)
30013003
fp.seek(0, 0)
30023004
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -3184,7 +3186,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
31843186
if(not fp):
31853187
return False
31863188
fp.seek(0, 0)
3187-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
3189+
elif(re.findall(__download_proto_support__, infile)):
31883190
fp = download_file_from_internet_file(infile)
31893191
fp.seek(0, 0)
31903192
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -3405,7 +3407,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
34053407
fp = MkTempFile()
34063408
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
34073409
fp = outfile
3408-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3410+
elif(re.findall(__download_proto_support__, outfile)):
34093411
fp = MkTempFile()
34103412
else:
34113413
fbasename = os.path.splitext(outfile)[0]
@@ -3441,7 +3443,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
34413443
outvar = fp.read()
34423444
fp.close()
34433445
return outvar
3444-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3446+
elif(re.findall(__upload_proto_support__, outfile)):
34453447
fp = CompressOpenFileAlt(
34463448
fp, compression, compressionlevel, compressionuselist, formatspecs)
34473449
fp.seek(0, 0)
@@ -3954,7 +3956,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
39543956
fp = MkTempFile()
39553957
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
39563958
fp = outfile
3957-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3959+
elif(re.findall(__upload_proto_support__, outfile)):
39583960
fp = MkTempFile()
39593961
else:
39603962
fbasename = os.path.splitext(outfile)[0]
@@ -3991,7 +3993,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
39913993
outvar = fp.read()
39923994
fp.close()
39933995
return outvar
3994-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3996+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
39953997
fp = CompressOpenFileAlt(
39963998
fp, compression, compressionlevel, compressionuselist, formatspecs)
39973999
fp.seek(0, 0)
@@ -4034,7 +4036,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
40344036
fp = MkTempFile()
40354037
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
40364038
fp = outfile
4037-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
4039+
elif(re.findall(__upload_proto_support__, outfile)):
40384040
fp = MkTempFile()
40394041
else:
40404042
fbasename = os.path.splitext(outfile)[0]
@@ -4071,7 +4073,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
40714073
outvar = fp.read()
40724074
fp.close()
40734075
return outvar
4074-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
4076+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
40754077
fp = CompressOpenFileAlt(
40764078
fp, compression, compressionlevel, compressionuselist, formatspecs)
40774079
fp.seek(0, 0)
@@ -5005,7 +5007,7 @@ def PackFoxFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
50055007
fp = MkTempFile()
50065008
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
50075009
fp = outfile
5008-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5010+
elif(re.findall(__upload_proto_support__, outfile)):
50095011
fp = MkTempFile()
50105012
else:
50115013
fbasename = os.path.splitext(outfile)[0]
@@ -5334,7 +5336,7 @@ def PackFoxFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compress
53345336
outvar = fp.read()
53355337
fp.close()
53365338
return outvar
5337-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5339+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
53385340
fp = CompressOpenFileAlt(
53395341
fp, compression, compressionlevel, compressionuselist, formatspecs)
53405342
fp.seek(0, 0)
@@ -5389,7 +5391,7 @@ def PackFoxFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
53895391
fp = MkTempFile()
53905392
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
53915393
fp = outfile
5392-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5394+
elif(re.findall(__upload_proto_support__, outfile)):
53935395
fp = MkTempFile()
53945396
else:
53955397
fbasename = os.path.splitext(outfile)[0]
@@ -5418,7 +5420,7 @@ def PackFoxFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
54185420
if(not infile):
54195421
return False
54205422
infile.seek(0, 0)
5421-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
5423+
elif(re.findall(__download_proto_support__, infile)):
54225424
infile = download_file_from_internet_file(infile)
54235425
infile.seek(0, 0)
54245426
if(not infile):
@@ -5635,7 +5637,7 @@ def PackFoxFileFromTarFile(infile, outfile, fmttype="auto", compression="auto",
56355637
outvar = fp.read()
56365638
fp.close()
56375639
return outvar
5638-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5640+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
56395641
fp = CompressOpenFileAlt(
56405642
fp, compression, compressionlevel, compressionuselist, formatspecs)
56415643
fp.seek(0, 0)
@@ -5686,7 +5688,7 @@ def PackFoxFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
56865688
fp = MkTempFile()
56875689
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
56885690
fp = outfile
5689-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5691+
elif(re.findall(__upload_proto_support__, outfile)):
56905692
fp = MkTempFile()
56915693
else:
56925694
fbasename = os.path.splitext(outfile)[0]
@@ -5715,7 +5717,7 @@ def PackFoxFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
57155717
if(not infile):
57165718
return False
57175719
infile.seek(0, 0)
5718-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
5720+
elif(re.findall(__download_proto_support__, infile)):
57195721
infile = download_file_from_internet_file(infile)
57205722
infile.seek(0, 0)
57215723
if(not infile):
@@ -5929,7 +5931,7 @@ def PackFoxFileFromZipFile(infile, outfile, fmttype="auto", compression="auto",
59295931
outvar = fp.read()
59305932
fp.close()
59315933
return outvar
5932-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5934+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
59335935
fp = CompressOpenFileAlt(
59345936
fp, compression, compressionlevel, compressionuselist, formatspecs)
59355937
fp.seek(0, 0)
@@ -5985,7 +5987,7 @@ def PackFoxFileFromRarFile(infile, outfile, fmttype="auto", compression="auto",
59855987
fp = MkTempFile()
59865988
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
59875989
fp = outfile
5988-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5990+
elif(re.findall(__upload_proto_support__, outfile)):
59895991
fp = MkTempFile()
59905992
else:
59915993
fbasename = os.path.splitext(outfile)[0]
@@ -6249,7 +6251,7 @@ def PackFoxFileFromRarFile(infile, outfile, fmttype="auto", compression="auto",
62496251
outvar = fp.read()
62506252
fp.close()
62516253
return outvar
6252-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
6254+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
62536255
fp = CompressOpenFileAlt(
62546256
fp, compression, compressionlevel, compressionuselist, formatspecs)
62556257
fp.seek(0, 0)
@@ -6305,7 +6307,7 @@ def PackFoxFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="au
63056307
fp = MkTempFile()
63066308
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
63076309
fp = outfile
6308-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
6310+
elif(re.findall(__upload_proto_support__, outfile)):
63096311
fp = MkTempFile()
63106312
else:
63116313
fbasename = os.path.splitext(outfile)[0]
@@ -6503,7 +6505,7 @@ def PackFoxFileFromSevenZipFile(infile, outfile, fmttype="auto", compression="au
65036505
outvar = fp.read()
65046506
fp.close()
65056507
return outvar
6506-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
6508+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
65076509
fp = CompressOpenFileAlt(
65086510
fp, compression, compressionlevel, compressionuselist, formatspecs)
65096511
fp.seek(0, 0)
@@ -6591,7 +6593,7 @@ def FoxFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, conte
65916593
if(not fp):
65926594
return False
65936595
fp.seek(0, 0)
6594-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
6596+
elif(re.findall(__download_proto_support__, infile)):
65956597
fp = download_file_from_internet_file(infile)
65966598
fp = UncompressFileAlt(fp, formatspecs)
65976599
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -6906,7 +6908,7 @@ def FoxFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=False,
69066908
if(not fp):
69076909
return False
69086910
fp.seek(0, 0)
6909-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
6911+
elif(re.findall(__download_proto_support__, infile)):
69106912
fp = download_file_from_internet_file(infile)
69116913
fp = UncompressFileAlt(fp, formatspecs)
69126914
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -7227,7 +7229,7 @@ def FoxFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_dict
72277229
if(not fp):
72287230
return False
72297231
fp.seek(0, 0)
7230-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
7232+
elif(re.findall(__download_proto_support__, infile)):
72317233
fp = download_file_from_internet_file(infile)
72327234
fp = UncompressFileAlt(fp, formatspecs)
72337235
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -7579,7 +7581,7 @@ def FoxFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=Fals
75797581
if(not fp):
75807582
return False
75817583
fp.seek(0, 0)
7582-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
7584+
elif(re.findall(__download_proto_support__, infile)):
75837585
fp = download_file_from_internet_file(infile)
75847586
fp = UncompressFileAlt(fp, formatspecs)
75857587
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -8198,7 +8200,7 @@ def RePackFoxFile(infile, outfile, fmttype="auto", compression="auto", compressw
81988200
fp = MkTempFile()
81998201
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
82008202
fp = outfile
8201-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
8203+
elif(re.findall(__upload_proto_support__, outfile)):
82028204
fp = MkTempFile()
82038205
else:
82048206
fbasename = os.path.splitext(outfile)[0]
@@ -8426,7 +8428,7 @@ def RePackFoxFile(infile, outfile, fmttype="auto", compression="auto", compressw
84268428
outvar = fp.read()
84278429
fp.close()
84288430
return outvar
8429-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
8431+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
84308432
fp = CompressOpenFileAlt(
84318433
fp, compression, compressionlevel, compressionuselist, formatspecs)
84328434
fp.seek(0, 0)
@@ -8806,7 +8808,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
88068808
if(not infile):
88078809
return False
88088810
infile.seek(0, 0)
8809-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
8811+
elif(re.findall(__download_proto_support__, infile)):
88108812
infile = download_file_from_internet_file(infile)
88118813
infile.seek(0, 0)
88128814
if(not infile):
@@ -8931,7 +8933,7 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
89318933
if(not infile):
89328934
return False
89338935
infile.seek(0, 0)
8934-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
8936+
elif(re.findall(__download_proto_support__, infile)):
89358937
infile = download_file_from_internet_file(infile)
89368938
infile.seek(0, 0)
89378939
if(not infile):

0 commit comments

Comments
 (0)