mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-26 05:49:44 +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)
|
remove(f)
|
||||||
except:
|
except:
|
||||||
pass
|
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…
x
Reference in New Issue
Block a user