mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 04:57:54 +00:00
fileutil.write: accept mode=, and use it in Node.write_config
I want mode="w" (i.e. text, with newline conversion) for code that writes newline-terminated strings (which should also be human readable) to files. I like to use things like "cat .tahoe/permutation-seed" without seeing the seed jammed together with the next command prompt.
This commit is contained in:
parent
7130a247cf
commit
ff64a0fef5
@ -279,7 +279,7 @@ class Node(service.MultiService):
|
||||
"""Write a string to a config file."""
|
||||
fn = os.path.join(self.basedir, name)
|
||||
try:
|
||||
open(fn, mode).write(value)
|
||||
fileutil.write(fn, value, mode)
|
||||
except EnvironmentError, e:
|
||||
self.log("Unable to write config file '%s'" % fn)
|
||||
self.log(e)
|
||||
|
@ -255,8 +255,8 @@ def write_atomically(target, contents, mode="b"):
|
||||
f.close()
|
||||
move_into_place(target+".tmp", target)
|
||||
|
||||
def write(path, data):
|
||||
wf = open(path, "wb")
|
||||
def write(path, data, mode="wb"):
|
||||
wf = open(path, mode)
|
||||
try:
|
||||
wf.write(data)
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user