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.
"""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)
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: