mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
pyutil: fileutil.open_or_create()
This commit is contained in:
parent
e040b85f5d
commit
723f4078a3
@ -178,3 +178,9 @@ def remove_if_possible(f):
|
||||
remove(f)
|
||||
except:
|
||||
pass
|
||||
|
||||
def open_or_create(fname, binarymode=True):
|
||||
try:
|
||||
return open(fname, binarymode and "r+b" or "r+")
|
||||
except EnvironmentError:
|
||||
return open(fname, binarymode and "w+b" or "w+")
|
||||
|
Loading…
Reference in New Issue
Block a user