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