@@ -1870,7 +1870,7 @@ def SevenZipFileCheck(infile):
18701870 return False
18711871
18721872def CheckCompressionType (infile , formatspecs = __file_format_multi_dict__ , filestart = 0 , closefp = True ):
1873- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ):
1873+ if (hasattr (infile , "read" )):
18741874 fp = infile
18751875 else :
18761876 try :
@@ -2052,10 +2052,10 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_multi_dict__, file
20522052 elif (py7zr_support and compresscheck == "7zipfile" and py7zr .is_7zfile (infile )):
20532053 return "7zipfile"
20542054 precfp = None
2055- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) and compresscheck in compressionsupport ):
2055+ if (hasattr (infile , "read" ) and compresscheck in compressionsupport ):
20562056 fp = UncompressFileAlt (infile , formatspecs , filestart )
20572057 curloc = fp .tell ()
2058- elif (hasattr (infile , "read" ) or hasattr ( infile , "write" ) and compresscheck not in compressionsupport ):
2058+ elif (hasattr (infile , "read" ) and compresscheck not in compressionsupport ):
20592059 fp = infile
20602060 else :
20612061 try :
@@ -2136,7 +2136,7 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_multi_dict__, file
21362136 if (prefp == binascii .unhexlify ("7061785f676c6f62616c" )):
21372137 filetype = "tarfile"
21382138 fp .seek (curloc , 0 )
2139- if (hasattr (precfp , "read" ) or hasattr ( precfp , "write" ) ):
2139+ if (hasattr (precfp , "read" )):
21402140 precfp .close ()
21412141 if (closefp ):
21422142 fp .close ()
@@ -2187,7 +2187,7 @@ def GetFileEncoding(infile, filestart=0, closefp=True):
21872187 fp = None
21882188
21892189 # --- Obtain a binary file object ---
2190- if hasattr (infile , "read" ) or hasattr ( infile , "write" ) :
2190+ if hasattr (infile , "read" ):
21912191 fp = infile
21922192 else :
21932193 try :
@@ -2271,7 +2271,7 @@ def GetBinaryFileType(infile, filestart=0, closefp=True):
22712271 data = infile [filestart :filestart + 560 ]
22722272 fp = None
22732273 else :
2274- fp = infile if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ) else None
2274+ fp = infile if (hasattr (infile , "read" )) else None
22752275 if fp is None :
22762276 try :
22772277 fp = open (infile , "rb" )
@@ -5518,7 +5518,7 @@ def ReadFileDataWithContentToList(fp, filestart=0, seekstart=0, seekend=0, listo
55185518
55195519
55205520def 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 ):
5521- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ):
5521+ if (hasattr (infile , "read" )):
55225522 fp = infile
55235523 try :
55245524 fp .seek (0 , 2 )
@@ -5629,7 +5629,7 @@ def ReadInMultipleFilesWithContentToArray(infile, fmttype="auto", filestart=0, s
56295629
56305630
56315631def 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 ):
5632- if (hasattr (infile , "read" ) or hasattr ( infile , "write" ) ):
5632+ if (hasattr (infile , "read" )):
56335633 fp = infile
56345634 try :
56355635 fp .seek (0 , 2 )
@@ -5894,7 +5894,7 @@ def MakeEmptyNeoFilePointer(fp, fmttype=__file_format_default__, checksumtype=["
58945894
58955895def MakeEmptyFile (outfile , fmttype = "auto" , compression = "auto" , compresswholefile = True , compressionlevel = None , compressionuselist = compressionlistalt , checksumtype = ["md5" , "md5" ], formatspecs = __file_format_multi_dict__ , saltkey = None , returnfp = False ):
58965896 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
5897- (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) )):
5897+ (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ))):
58985898 get_in_ext = os .path .splitext (outfile )
58995899 tmpfmt = GetKeyByFormatExtension (get_in_ext [1 ], formatspecs = __file_format_multi_dict__ )
59005900 if (tmpfmt is None and get_in_ext [1 ]!= "" ):
@@ -5911,7 +5911,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
59115911 elif (IsNestedDict (formatspecs ) and fmttype not in formatspecs ):
59125912 fmttype = __file_format_default__
59135913 formatspecs = formatspecs [fmttype ]
5914- if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) ):
5914+ if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" )):
59155915 if (os .path .exists (outfile )):
59165916 try :
59175917 os .unlink (outfile )
@@ -5920,7 +5920,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
59205920 if (outfile == "-" or outfile is None ):
59215921 verbose = False
59225922 fp = MkTempFile ()
5923- elif (hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
5923+ elif (hasattr (outfile , "read" )):
59245924 fp = outfile
59255925 return MakeEmptyFilePointer (fp , fmttype , checksumtype , formatspecs , saltkey )
59265926 elif (re .findall (__upload_proto_support__ , outfile ) and pywwwget ):
@@ -5935,7 +5935,7 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
59355935 except PermissionError :
59365936 return False
59375937 AppendFileHeader (fp , fmttype , 0 , "UTF-8" , [], {}, checksumtype , formatspecs , saltkey )
5938- if (outfile == "-" or outfile is None or hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
5938+ if (outfile == "-" or outfile is None or hasattr (outfile , "read" )):
59395939 fp = CompressOpenFileAlt (
59405940 fp , compression , compressionlevel , compressionuselist , formatspecs )
59415941 try :
@@ -6094,7 +6094,7 @@ def AppendFilesWithContentFromInFile(infile, fp, fmttype="auto", listtype="dir",
60946094
60956095def 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 ):
60966096 if (IsNestedDict (formatspecs ) and fmttype == "auto" and
6097- (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) )):
6097+ (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ))):
60986098 get_in_ext = os .path .splitext (outfile )
60996099 tmpfmt = GetKeyByFormatExtension (get_in_ext [1 ], formatspecs = __file_format_multi_dict__ )
61006100 if (tmpfmt is None and get_in_ext [1 ]!= "" ):
@@ -6111,7 +6111,7 @@ def AppendFilesWithContentFromInFileToOutFile(infiles, outfile, listtype="dir",
61116111 elif (IsNestedDict (formatspecs ) and fmttype not in formatspecs ):
61126112 fmttype = __file_format_default__
61136113 ckformatspecs = formatspecs [fmttype ]
6114- if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" ) and not hasattr ( outfile , "write" ) ):
6114+ if (outfile != "-" and outfile is not None and not hasattr (outfile , "read" )):
61156115 outfile = RemoveWindowsPath (outfile )
61166116 if (os .path .exists (outfile )):
61176117 try :
@@ -6121,7 +6121,7 @@ def AppendFilesWithContentFromInFileToOutFile(infiles, outfile, listtype="dir",
61216121 if (outfile == "-" or outfile is None ):
61226122 verbose = False
61236123 fp = MkTempFile ()
6124- elif (hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
6124+ elif (hasattr (outfile , "read" )):
61256125 fp = outfile
61266126 elif (re .findall (__upload_proto_support__ , outfile ) and pywwwget ):
61276127 fp = MkTempFile ()
@@ -6135,7 +6135,7 @@ def AppendFilesWithContentFromInFileToOutFile(infiles, outfile, listtype="dir",
61356135 except PermissionError :
61366136 return False
61376137 AppendFilesWithContentFromInFile (infiles , fp , fmttype , listtype , extradata , jsondata , compression , compresswholefile , compressionlevel , compressionuselist , checksumtype , formatspecs , saltkey , verbose )
6138- if (outfile == "-" or outfile is None or hasattr (outfile , "read" ) or hasattr ( outfile , "write" ) ):
6138+ if (outfile == "-" or outfile is None or hasattr (outfile , "read" )):
61396139 fp = CompressOpenFileAlt (
61406140 fp , compression , compressionlevel , compressionuselist , formatspecs )
61416141 try :
@@ -6860,7 +6860,7 @@ def AppendFilesWithContentFromBSDTarFileToList(infile, fmttype="auto", extradata
68606860 formatspecs = formatspecs [fmttype ]
68616861 elif (IsNestedDict (formatspecs ) and fmttype not in formatspecs ):
68626862 fmttype = __file_format_default__
6863- formatspecs = formatspecs [fmttype ]
6863+ formatspecs = formatspecs [fmttype ]
68646864 curinode = 0
68656865 curfid = 0
68666866 inodelist = []
0 commit comments