Simplify with .writable() method.

Addresses https://github.com/jensengroup/propka-3.1/pull/50#discussion_r434349737
This commit is contained in:
Nathan Baker
2020-06-03 17:49:19 -07:00
parent 1d17cb05ed
commit 7085271ad5

View File

@@ -13,8 +13,7 @@ def open_file_for_writing(input_file):
then will attempt to get file mode. then will attempt to get file mode.
""" """
try: try:
mode = input_file.mode if not input_file.writable():
if not ("w" in mode or "a" in mode or "+" in mode):
raise IOError("File/stream not open for writing") raise IOError("File/stream not open for writing")
return input_file return input_file
except AttributeError: except AttributeError: