Skip to content

Commit 9866457

Browse files
authored
Add files via upload
1 parent 1c0413b commit 9866457

1 file changed

Lines changed: 30 additions & 29 deletions

File tree

pyarchivefile.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def get_default_threads():
264264
# os.cpu_count() might not be available in some environments
265265
return 1
266266

267-
267+
__upload_proto_support__ = "^(ftp|ftps|sftp):\\/\\/"
268+
__download_proto_support__ = "^(http|https|ftp|ftps|sftp):\\/\\/"
268269
__use_pysftp__ = False
269270
if(not havepysftp):
270271
__use_pysftp__ = False
@@ -2985,7 +2986,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
29852986
if(not fp):
29862987
return False
29872988
fp.seek(0, 0)
2988-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
2989+
elif(re.findall(__download_proto_support__, infile)):
29892990
fp = download_file_from_internet_file(infile)
29902991
fp.seek(0, 0)
29912992
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -3173,7 +3174,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
31733174
if(not fp):
31743175
return False
31753176
fp.seek(0, 0)
3176-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
3177+
elif(re.findall(__download_proto_support__, infile)):
31773178
fp = download_file_from_internet_file(infile)
31783179
fp.seek(0, 0)
31793180
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -3394,7 +3395,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
33943395
fp = MkTempFile()
33953396
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
33963397
fp = outfile
3397-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3398+
elif(re.findall(__upload_proto_support__, outfile)):
33983399
fp = MkTempFile()
33993400
else:
34003401
fbasename = os.path.splitext(outfile)[0]
@@ -3430,7 +3431,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
34303431
outvar = fp.read()
34313432
fp.close()
34323433
return outvar
3433-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3434+
elif(re.findall(__upload_proto_support__, outfile)):
34343435
fp = CompressOpenFileAlt(
34353436
fp, compression, compressionlevel, compressionuselist, formatspecs)
34363437
fp.seek(0, 0)
@@ -3943,7 +3944,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
39433944
fp = MkTempFile()
39443945
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
39453946
fp = outfile
3946-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3947+
elif(re.findall(__upload_proto_support__, outfile)):
39473948
fp = MkTempFile()
39483949
else:
39493950
fbasename = os.path.splitext(outfile)[0]
@@ -3980,7 +3981,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
39803981
outvar = fp.read()
39813982
fp.close()
39823983
return outvar
3983-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
3984+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
39843985
fp = CompressOpenFileAlt(
39853986
fp, compression, compressionlevel, compressionuselist, formatspecs)
39863987
fp.seek(0, 0)
@@ -4023,7 +4024,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
40234024
fp = MkTempFile()
40244025
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
40254026
fp = outfile
4026-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
4027+
elif(re.findall(__upload_proto_support__, outfile)):
40274028
fp = MkTempFile()
40284029
else:
40294030
fbasename = os.path.splitext(outfile)[0]
@@ -4060,7 +4061,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
40604061
outvar = fp.read()
40614062
fp.close()
40624063
return outvar
4063-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
4064+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
40644065
fp = CompressOpenFileAlt(
40654066
fp, compression, compressionlevel, compressionuselist, formatspecs)
40664067
fp.seek(0, 0)
@@ -4994,7 +4995,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
49944995
fp = MkTempFile()
49954996
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
49964997
fp = outfile
4997-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
4998+
elif(re.findall(__upload_proto_support__, outfile)):
49984999
fp = MkTempFile()
49995000
else:
50005001
fbasename = os.path.splitext(outfile)[0]
@@ -5323,7 +5324,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
53235324
outvar = fp.read()
53245325
fp.close()
53255326
return outvar
5326-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5327+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
53275328
fp = CompressOpenFileAlt(
53285329
fp, compression, compressionlevel, compressionuselist, formatspecs)
53295330
fp.seek(0, 0)
@@ -5378,7 +5379,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
53785379
fp = MkTempFile()
53795380
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
53805381
fp = outfile
5381-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5382+
elif(re.findall(__upload_proto_support__, outfile)):
53825383
fp = MkTempFile()
53835384
else:
53845385
fbasename = os.path.splitext(outfile)[0]
@@ -5407,7 +5408,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
54075408
if(not infile):
54085409
return False
54095410
infile.seek(0, 0)
5410-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
5411+
elif(re.findall(__download_proto_support__, infile)):
54115412
infile = download_file_from_internet_file(infile)
54125413
infile.seek(0, 0)
54135414
if(not infile):
@@ -5624,7 +5625,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
56245625
outvar = fp.read()
56255626
fp.close()
56265627
return outvar
5627-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5628+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
56285629
fp = CompressOpenFileAlt(
56295630
fp, compression, compressionlevel, compressionuselist, formatspecs)
56305631
fp.seek(0, 0)
@@ -5675,7 +5676,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
56755676
fp = MkTempFile()
56765677
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
56775678
fp = outfile
5678-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5679+
elif(re.findall(__upload_proto_support__, outfile)):
56795680
fp = MkTempFile()
56805681
else:
56815682
fbasename = os.path.splitext(outfile)[0]
@@ -5704,7 +5705,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
57045705
if(not infile):
57055706
return False
57065707
infile.seek(0, 0)
5707-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
5708+
elif(re.findall(__download_proto_support__, infile)):
57085709
infile = download_file_from_internet_file(infile)
57095710
infile.seek(0, 0)
57105711
if(not infile):
@@ -5918,7 +5919,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
59185919
outvar = fp.read()
59195920
fp.close()
59205921
return outvar
5921-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5922+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
59225923
fp = CompressOpenFileAlt(
59235924
fp, compression, compressionlevel, compressionuselist, formatspecs)
59245925
fp.seek(0, 0)
@@ -5974,7 +5975,7 @@ def PackArchiveFileFromRarFile(infile, outfile, fmttype="auto", compression="aut
59745975
fp = MkTempFile()
59755976
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
59765977
fp = outfile
5977-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
5978+
elif(re.findall(__upload_proto_support__, outfile)):
59785979
fp = MkTempFile()
59795980
else:
59805981
fbasename = os.path.splitext(outfile)[0]
@@ -6238,7 +6239,7 @@ def PackArchiveFileFromRarFile(infile, outfile, fmttype="auto", compression="aut
62386239
outvar = fp.read()
62396240
fp.close()
62406241
return outvar
6241-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
6242+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
62426243
fp = CompressOpenFileAlt(
62436244
fp, compression, compressionlevel, compressionuselist, formatspecs)
62446245
fp.seek(0, 0)
@@ -6294,7 +6295,7 @@ def PackArchiveFileFromSevenZipFile(infile, outfile, fmttype="auto", compression
62946295
fp = MkTempFile()
62956296
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
62966297
fp = outfile
6297-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
6298+
elif(re.findall(__upload_proto_support__, outfile)):
62986299
fp = MkTempFile()
62996300
else:
63006301
fbasename = os.path.splitext(outfile)[0]
@@ -6492,7 +6493,7 @@ def PackArchiveFileFromSevenZipFile(infile, outfile, fmttype="auto", compression
64926493
outvar = fp.read()
64936494
fp.close()
64946495
return outvar
6495-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
6496+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
64966497
fp = CompressOpenFileAlt(
64976498
fp, compression, compressionlevel, compressionuselist, formatspecs)
64986499
fp.seek(0, 0)
@@ -6580,7 +6581,7 @@ def ArchiveFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, c
65806581
if(not fp):
65816582
return False
65826583
fp.seek(0, 0)
6583-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
6584+
elif(re.findall(__download_proto_support__, infile)):
65846585
fp = download_file_from_internet_file(infile)
65856586
fp = UncompressFileAlt(fp, formatspecs)
65866587
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -6895,7 +6896,7 @@ def ArchiveFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=Fa
68956896
if(not fp):
68966897
return False
68976898
fp.seek(0, 0)
6898-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
6899+
elif(re.findall(__download_proto_support__, infile)):
68996900
fp = download_file_from_internet_file(infile)
69006901
fp = UncompressFileAlt(fp, formatspecs)
69016902
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -7216,7 +7217,7 @@ def ArchiveFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_
72167217
if(not fp):
72177218
return False
72187219
fp.seek(0, 0)
7219-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
7220+
elif(re.findall(__download_proto_support__, infile)):
72207221
fp = download_file_from_internet_file(infile)
72217222
fp = UncompressFileAlt(fp, formatspecs)
72227223
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -7568,7 +7569,7 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
75687569
if(not fp):
75697570
return False
75707571
fp.seek(0, 0)
7571-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
7572+
elif(re.findall(__download_proto_support__, infile)):
75727573
fp = download_file_from_internet_file(infile)
75737574
fp = UncompressFileAlt(fp, formatspecs)
75747575
compresscheck = CheckCompressionType(fp, formatspecs, False)
@@ -8187,7 +8188,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
81878188
fp = MkTempFile()
81888189
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
81898190
fp = outfile
8190-
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
8191+
elif(re.findall(__upload_proto_support__, outfile)):
81918192
fp = MkTempFile()
81928193
else:
81938194
fbasename = os.path.splitext(outfile)[0]
@@ -8415,7 +8416,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
84158416
outvar = fp.read()
84168417
fp.close()
84178418
return outvar
8418-
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
8419+
elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)):
84198420
fp = CompressOpenFileAlt(
84208421
fp, compression, compressionlevel, compressionuselist, formatspecs)
84218422
fp.seek(0, 0)
@@ -8795,7 +8796,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
87958796
if(not infile):
87968797
return False
87978798
infile.seek(0, 0)
8798-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
8799+
elif(re.findall(__download_proto_support__, infile)):
87998800
infile = download_file_from_internet_file(infile)
88008801
infile.seek(0, 0)
88018802
if(not infile):
@@ -8920,7 +8921,7 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
89208921
if(not infile):
89218922
return False
89228923
infile.seek(0, 0)
8923-
elif(re.findall("^(http|https|ftp|ftps|sftp):\\/\\/", infile)):
8924+
elif(re.findall(__download_proto_support__, infile)):
89248925
infile = download_file_from_internet_file(infile)
89258926
infile.seek(0, 0)
89268927
if(not infile):

0 commit comments

Comments
 (0)