@@ -1877,7 +1877,7 @@ def SevenZipFileCheck(infile):
18771877 return False
18781878
18791879def CheckCompressionType (infile , formatspecs = __file_format_multi_dict__ , filestart = 0 , closefp = True ):
1880- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ):
1880+ if (hasattr (infile , "read" )):
18811881 fp = infile
18821882 else :
18831883 try :
@@ -2059,10 +2059,10 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_multi_dict__, file
20592059 elif (py7zr_support and compresscheck == "7zipfile" and py7zr .is_7zfile (infile )):
20602060 return "7zipfile"
20612061 precfp = None
2062- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) and compresscheck in compressionsupport ):
2062+ if (hasattr (infile , "read" ) and compresscheck in compressionsupport ):
20632063 fp = UncompressFileAlt (infile , formatspecs , filestart )
20642064 curloc = fp .tell ()
2065- elif (hasattr (infile , "read" ) or hasattr ( infile , "write" ) and compresscheck not in compressionsupport ):
2065+ elif (hasattr (infile , "read" ) and compresscheck not in compressionsupport ):
20662066 fp = infile
20672067 else :
20682068 try :
@@ -2143,7 +2143,7 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_multi_dict__, file
21432143 if (prefp == binascii .unhexlify ("7061785f676c6f62616c" )):
21442144 filetype = "tarfile"
21452145 fp .seek (curloc , 0 )
2146- if (hasattr (precfp , "read" ) or hasattr ( precfp , "write" ) ):
2146+ if (hasattr (precfp , "read" )):
21472147 precfp .close ()
21482148 if (closefp ):
21492149 fp .close ()
@@ -2194,7 +2194,7 @@ def GetFileEncoding(infile, filestart=0, closefp=True):
21942194 fp = None
21952195
21962196 # --- Obtain a binary file object ---
2197- if hasattr (infile , "read" ) or hasattr ( infile , "write" ) :
2197+ if hasattr (infile , "read" ):
21982198 fp = infile
21992199 else :
22002200 try :
@@ -2278,7 +2278,7 @@ def GetBinaryFileType(infile, filestart=0, closefp=True):
22782278 data = infile [filestart :filestart + 560 ]
22792279 fp = None
22802280 else :
2281- fp = infile if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ) else None
2281+ fp = infile if (hasattr (infile , "read" )) else None
22822282 if fp is None :
22832283 try :
22842284 fp = open (infile , "rb" )
@@ -5525,7 +5525,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
55255525
55265526
55275527def ReadInFileWithContentToArray (infile , fmttype = "auto" , filestart = 0 , seekstart = 0 , seekend = 0 , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_multi_dict__ , saltkey = None , seektoend = False ):
5528- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ):
5528+ if (hasattr (infile , "read" )):
55295529 fp = infile
55305530 try :
55315531 fp .seek (0 , 2 )
@@ -5636,7 +5636,7 @@ def ReadInMultipleFilesWithContentToArray(infile, fmttype="auto", filestart=0, s
56365636
56375637
56385638def ReadInFileWithContentToList (infile , fmttype = "auto" , filestart = 0 , seekstart = 0 , seekend = 0 , listonly = False , contentasfile = True , uncompress = True , skipchecksum = False , formatspecs = __file_format_multi_dict__ , saltkey = None , seektoend = False ):
5639- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ):
5639+ if (hasattr (infile , "read" )):
56405640 fp = infile
56415641 try :
56425642 fp .seek (0 , 2 )
@@ -5901,7 +5901,7 @@ def MakeEmptyFoxFilePointer(fp, fmttype=__file_format_default__, checksumtype=["
59015901
59025902def MakeEmptyFile (outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["md5" , "md5" ], formatspecs = __file_format_multi_dict__ , saltkey = None , returnfp = False ):
59035903 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
5904- (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) )):
5904+ (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ))):
59055905 get_in_ext = os .path .splitext (outfile )
59065906 tmpfmt = GetKeyByFormatExtension (get_in_ext [1 ], formatspecs = __file_format_multi_dict__ )
59075907 if (tmpfmt is None and get_in_ext [1 ]!= "" ):
@@ -5918,7 +5918,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
59185918 elif (IsNestedDict (formatspecs ) and fmttype not in formatspecs ):
59195919 fmttype = __file_format_default__
59205920 formatspecs = formatspecs [fmttype ]
5921- if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) ):
5921+ if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" )):
59225922 if (os .path .exists (outfile )):
59235923 try :
59245924 os .unlink (outfile )
@@ -5927,7 +5927,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
59275927 if (outfile == "-" or outfile is None ):
59285928 verbose = False
59295929 fp = MkTempFile ()
5930- elif (hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
5930+ elif (hasattr (outfile , "read" )):
59315931 fp = outfile
59325932 return MakeEmptyFilePointer (fp , fmttype , checksumtype , formatspecs , saltkey )
59335933 elif (re .findall (__upload_proto_support__ , outfile ) and pywwwget ):
@@ -5942,7 +5942,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
59425942 except PermissionError :
59435943 return False
59445944 AppendFileHeader (fp , fmttype , 0 , "UTF-8" , [], {}, checksumtype , formatspecs , saltkey )
5945- if (outfile == "-" or outfile is None or hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
5945+ if (outfile == "-" or outfile is None or hasattr (outfile , "read" )):
59465946 fp = CompressOpenFileAlt (
59475947 fp , compression , compressionlevel , compressionuselist , formatspecs )
59485948 try :
@@ -6101,7 +6101,7 @@ def AppendFilesWithContentFromInFile(infile, fp, fmttype="auto", listtype="dir",
61016101
61026102def AppendFilesWithContentFromInFileToOutFile (infiles , outfile , listtype = "dir" , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , extradata = [], jsondata = {}, checksumtype = ["md5" , "md5" , "md5" , "md5" , "md5" ], formatspecs = __file_format_multi_dict__ , saltkey = None , verbose = False , returnfp = False ):
61036103 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
6104- (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) )):
6104+ (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ))):
61056105 get_in_ext = os .path .splitext (outfile )
61066106 tmpfmt = GetKeyByFormatExtension (get_in_ext [1 ], formatspecs = __file_format_multi_dict__ )
61076107 if (tmpfmt is None and get_in_ext [1 ]!= "" ):
@@ -6118,7 +6118,7 @@ def AppendFilesWithContentFromInFileToOutFile(infiles, outfile, listtype="dir",
61186118 elif (IsNestedDict (formatspecs ) and fmttype not in formatspecs ):
61196119 fmttype = __file_format_default__
61206120 ckformatspecs = formatspecs [fmttype ]
6121- if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) ):
6121+ if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" )):
61226122 outfile = RemoveWindowsPath (outfile )
61236123 if (os .path .exists (outfile )):
61246124 try :
@@ -6128,7 +6128,7 @@ def AppendFilesWithContentFromInFileToOutFile(infiles, outfile, listtype="dir",
61286128 if (outfile == "-" or outfile is None ):
61296129 verbose = False
61306130 fp = MkTempFile ()
6131- elif (hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
6131+ elif (hasattr (outfile , "read" )):
61326132 fp = outfile
61336133 elif (re .findall (__upload_proto_support__ , outfile ) and pywwwget ):
61346134 fp = MkTempFile ()
@@ -6142,7 +6142,7 @@ def AppendFilesWithContentFromInFileToOutFile(infiles, outfile, listtype="dir",
61426142 except PermissionError :
61436143 return False
61446144 AppendFilesWithContentFromInFile (infiles , fp , fmttype , listtype , extradata , jsondata , compression , compresswholefile , compressionlevel , compressionuselist , checksumtype , formatspecs , saltkey , verbose )
6145- if (outfile == "-" or outfile is None or hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
6145+ if (outfile == "-" or outfile is None or hasattr (outfile , "read" )):
61466146 fp = CompressOpenFileAlt (
61476147 fp , compression , compressionlevel , compressionuselist , formatspecs )
61486148 try :
@@ -6867,7 +6867,7 @@ def AppendFilesWithContentFromBSDTarFileToList(infile, fmttype="auto", extradata
68676867 formatspecs = formatspecs [fmttype ]
68686868 elif (IsNestedDict (formatspecs ) and fmttype not in formatspecs ):
68696869 fmttype = __file_format_default__
6870- formatspecs = formatspecs [fmttype ]
6870+ formatspecs = formatspecs [fmttype ]
68716871 curinode = 0
68726872 curfid = 0
68736873 inodelist = []
0 commit comments