|
16 | 16 | import hashlib |
17 | 17 | import inspect |
18 | 18 | import tempfile |
19 | | -from .pywwwget import upload_file_to_internet_file, download_file_from_internet_file |
| 19 | +pywwwget = False |
| 20 | +try: |
| 21 | + from .pywwwget import upload_file_to_internet_file, download_file_from_internet_file |
| 22 | + pywwwget = True |
| 23 | +except ImportError: |
| 24 | + pywwwget = False |
20 | 25 | from io import open |
21 | 26 |
|
22 | 27 | # RAR file support |
@@ -4399,7 +4404,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", filestart=0, seekstart= |
4399 | 4404 | outfsize = fp.tell() |
4400 | 4405 | fp.seek(filestart, 0) |
4401 | 4406 | currentfilepos = fp.tell() |
4402 | | - elif(re.findall(__download_proto_support__, infile)): |
| 4407 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
4403 | 4408 | fp = download_file_from_internet_file(infile) |
4404 | 4409 | try: |
4405 | 4410 | fp.seek(0, 2) |
@@ -4516,7 +4521,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", filestart=0, seekstart=0 |
4516 | 4521 | outfsize = fp.tell() |
4517 | 4522 | fp.seek(filestart, 0) |
4518 | 4523 | currentfilepos = fp.tell() |
4519 | | - elif(re.findall(__download_proto_support__, infile)): |
| 4524 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
4520 | 4525 | fp = download_file_from_internet_file(infile) |
4521 | 4526 | try: |
4522 | 4527 | fp.seek(0, 2) |
@@ -4781,7 +4786,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile |
4781 | 4786 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
4782 | 4787 | fp = outfile |
4783 | 4788 | return MakeEmptyFilePointer(fp, fmttype, checksumtype, formatspecs, saltkey) |
4784 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 4789 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
4785 | 4790 | fp = MkTempFile() |
4786 | 4791 | else: |
4787 | 4792 | fbasename = os.path.splitext(outfile)[0] |
@@ -4810,7 +4815,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile |
4810 | 4815 | outvar = fp.read() |
4811 | 4816 | fp.close() |
4812 | 4817 | return outvar |
4813 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 4818 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
4814 | 4819 | fp = CompressOpenFileAlt( |
4815 | 4820 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
4816 | 4821 | fp.seek(0, 0) |
@@ -5277,7 +5282,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c |
5277 | 5282 | if(not infile): |
5278 | 5283 | return False |
5279 | 5284 | infile.seek(0, 0) |
5280 | | - elif(re.findall(__download_proto_support__, infile)): |
| 5285 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
5281 | 5286 | infile = download_file_from_internet_file(infile) |
5282 | 5287 | infile.seek(0, 0) |
5283 | 5288 | if(not infile): |
@@ -5505,7 +5510,7 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c |
5505 | 5510 | if(not infile): |
5506 | 5511 | return False |
5507 | 5512 | infile.seek(0, 0) |
5508 | | - elif(re.findall(__download_proto_support__, infile)): |
| 5513 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
5509 | 5514 | infile = download_file_from_internet_file(infile) |
5510 | 5515 | infile.seek(0, 0) |
5511 | 5516 | if(not infile): |
@@ -6314,7 +6319,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt |
6314 | 6319 | fp = MkTempFile() |
6315 | 6320 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6316 | 6321 | fp = outfile |
6317 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6322 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6318 | 6323 | fp = MkTempFile() |
6319 | 6324 | else: |
6320 | 6325 | fbasename = os.path.splitext(outfile)[0] |
@@ -6343,7 +6348,7 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt |
6343 | 6348 | outvar = fp.read() |
6344 | 6349 | fp.close() |
6345 | 6350 | return outvar |
6346 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6351 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6347 | 6352 | fp = CompressOpenFileAlt( |
6348 | 6353 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6349 | 6354 | fp.seek(0, 0) |
@@ -6399,7 +6404,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty |
6399 | 6404 | fp = MkTempFile() |
6400 | 6405 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6401 | 6406 | fp = outfile |
6402 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6407 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6403 | 6408 | fp = MkTempFile() |
6404 | 6409 | else: |
6405 | 6410 | fbasename = os.path.splitext(outfile)[0] |
@@ -6428,7 +6433,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty |
6428 | 6433 | outvar = fp.read() |
6429 | 6434 | fp.close() |
6430 | 6435 | return outvar |
6431 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6436 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6432 | 6437 | fp = CompressOpenFileAlt( |
6433 | 6438 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6434 | 6439 | fp.seek(0, 0) |
@@ -6504,7 +6509,7 @@ def AppendReadInFileWithContentToOutFile(infiles, outfile, fmttype="auto", compr |
6504 | 6509 | fp = MkTempFile() |
6505 | 6510 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6506 | 6511 | fp = outfile |
6507 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6512 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6508 | 6513 | fp = MkTempFile() |
6509 | 6514 | else: |
6510 | 6515 | fbasename = os.path.splitext(outfile)[0] |
@@ -6533,7 +6538,7 @@ def AppendReadInFileWithContentToOutFile(infiles, outfile, fmttype="auto", compr |
6533 | 6538 | outvar = fp.read() |
6534 | 6539 | fp.close() |
6535 | 6540 | return outvar |
6536 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6541 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6537 | 6542 | fp = CompressOpenFileAlt( |
6538 | 6543 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6539 | 6544 | fp.seek(0, 0) |
@@ -6591,7 +6596,7 @@ def AppendFilesWithContentFromTarFileToOutFile(infiles, outfile, fmttype="auto", |
6591 | 6596 | fp = MkTempFile() |
6592 | 6597 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6593 | 6598 | fp = outfile |
6594 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6599 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6595 | 6600 | fp = MkTempFile() |
6596 | 6601 | else: |
6597 | 6602 | fbasename = os.path.splitext(outfile)[0] |
@@ -6620,7 +6625,7 @@ def AppendFilesWithContentFromTarFileToOutFile(infiles, outfile, fmttype="auto", |
6620 | 6625 | outvar = fp.read() |
6621 | 6626 | fp.close() |
6622 | 6627 | return outvar |
6623 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6628 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6624 | 6629 | fp = CompressOpenFileAlt( |
6625 | 6630 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6626 | 6631 | fp.seek(0, 0) |
@@ -6678,7 +6683,7 @@ def AppendFilesWithContentFromZipFileToOutFile(infiles, outfile, fmttype="auto", |
6678 | 6683 | fp = MkTempFile() |
6679 | 6684 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6680 | 6685 | fp = outfile |
6681 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6686 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6682 | 6687 | fp = MkTempFile() |
6683 | 6688 | else: |
6684 | 6689 | fbasename = os.path.splitext(outfile)[0] |
@@ -6707,7 +6712,7 @@ def AppendFilesWithContentFromZipFileToOutFile(infiles, outfile, fmttype="auto", |
6707 | 6712 | outvar = fp.read() |
6708 | 6713 | fp.close() |
6709 | 6714 | return outvar |
6710 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6715 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6711 | 6716 | fp = CompressOpenFileAlt( |
6712 | 6717 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6713 | 6718 | fp.seek(0, 0) |
@@ -6769,7 +6774,7 @@ def AppendFilesWithContentFromRarFileToOutFile(infiles, outfile, fmttype="auto", |
6769 | 6774 | fp = MkTempFile() |
6770 | 6775 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6771 | 6776 | fp = outfile |
6772 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6777 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6773 | 6778 | fp = MkTempFile() |
6774 | 6779 | else: |
6775 | 6780 | fbasename = os.path.splitext(outfile)[0] |
@@ -6798,7 +6803,7 @@ def AppendFilesWithContentFromRarFileToOutFile(infiles, outfile, fmttype="auto", |
6798 | 6803 | outvar = fp.read() |
6799 | 6804 | fp.close() |
6800 | 6805 | return outvar |
6801 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6806 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6802 | 6807 | fp = CompressOpenFileAlt( |
6803 | 6808 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6804 | 6809 | fp.seek(0, 0) |
@@ -6860,7 +6865,7 @@ def AppendFilesWithContentFromSevenZipFileToOutFile(infiles, outfile, fmttype="a |
6860 | 6865 | fp = MkTempFile() |
6861 | 6866 | elif(hasattr(outfile, "read") or hasattr(outfile, "write")): |
6862 | 6867 | fp = outfile |
6863 | | - elif(re.findall(__upload_proto_support__, outfile)): |
| 6868 | + elif(re.findall(__upload_proto_support__, outfile) and pywwwget): |
6864 | 6869 | fp = MkTempFile() |
6865 | 6870 | else: |
6866 | 6871 | fbasename = os.path.splitext(outfile)[0] |
@@ -6889,7 +6894,7 @@ def AppendFilesWithContentFromSevenZipFileToOutFile(infiles, outfile, fmttype="a |
6889 | 6894 | outvar = fp.read() |
6890 | 6895 | fp.close() |
6891 | 6896 | return outvar |
6892 | | - elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile)): |
| 6897 | + elif((not hasattr(outfile, "read") and not hasattr(outfile, "write")) and re.findall(__upload_proto_support__, outfile) and pywwwget): |
6893 | 6898 | fp = CompressOpenFileAlt( |
6894 | 6899 | fp, compression, compressionlevel, compressionuselist, formatspecs) |
6895 | 6900 | fp.seek(0, 0) |
@@ -7134,7 +7139,7 @@ def CatFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_form |
7134 | 7139 | if(not fp): |
7135 | 7140 | return False |
7136 | 7141 | fp.seek(filestart, 0) |
7137 | | - elif(re.findall(__download_proto_support__, infile)): |
| 7142 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
7138 | 7143 | fp = download_file_from_internet_file(infile) |
7139 | 7144 | fp = UncompressFileAlt(fp, formatspecs, filestart) |
7140 | 7145 | compresscheck = CheckCompressionType(fp, formatspecs, 0, False) |
@@ -8071,7 +8076,7 @@ def RePackCatFile(infile, outfile, fmttype="auto", compression="auto", compressw |
8071 | 8076 | pass |
8072 | 8077 | return outvar |
8073 | 8078 | elif ((not hasattr(outfile, "read") and not hasattr(outfile, "write")) |
8074 | | - and re.findall(__upload_proto_support__, outfile)): |
| 8079 | + and re.findall(__upload_proto_support__, outfile) and pywwwget): |
8075 | 8080 | fp = CompressOpenFileAlt(fp, compression, compressionlevel, compressionuselist, formatspecs) |
8076 | 8081 | fp.seek(0, 0) |
8077 | 8082 | upload_file_to_internet_file(fp, outfile) |
@@ -8514,7 +8519,7 @@ def TarFileListFiles(infile, formatspecs=__file_format_multi_dict__, verbose=Fal |
8514 | 8519 | if(not infile): |
8515 | 8520 | return False |
8516 | 8521 | infile.seek(0, 0) |
8517 | | - elif(re.findall(__download_proto_support__, infile)): |
| 8522 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
8518 | 8523 | infile = download_file_from_internet_file(infile) |
8519 | 8524 | infile.seek(0, 0) |
8520 | 8525 | if(not infile): |
@@ -8636,7 +8641,7 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False): |
8636 | 8641 | if(not infile): |
8637 | 8642 | return False |
8638 | 8643 | infile.seek(0, 0) |
8639 | | - elif(re.findall(__download_proto_support__, infile)): |
| 8644 | + elif(re.findall(__download_proto_support__, infile) and pywwwget): |
8640 | 8645 | infile = download_file_from_internet_file(infile) |
8641 | 8646 | infile.seek(0, 0) |
8642 | 8647 | if(not infile): |
|
0 commit comments