Changeset ff64a0fe in trunk


Ignore:
Timestamp:
2013-03-19T00:34:57Z (12 years ago)
Author:
Brian Warner <warner@…>
Branches:
master
Children:
3e26c78
Parents:
7130a24
git-author:
Brian Warner <warner@…> (2013-03-19 00:30:57)
git-committer:
Brian Warner <warner@…> (2013-03-19 00:34:57)
Message:

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.

Location:
src/allmydata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/node.py

    r7130a24 rff64a0fe  
    280280        fn = os.path.join(self.basedir, name)
    281281        try:
    282             open(fn, mode).write(value)
     282            fileutil.write(fn, value, mode)
    283283        except EnvironmentError, e:
    284284            self.log("Unable to write config file '%s'" % fn)
  • TabularUnified src/allmydata/util/fileutil.py

    r7130a24 rff64a0fe  
    256256    move_into_place(target+".tmp", target)
    257257
    258 def write(path, data):
    259     wf = open(path, "wb")
     258def write(path, data, mode="wb"):
     259    wf = open(path, mode)
    260260    try:
    261261        wf.write(data)
Note: See TracChangeset for help on using the changeset viewer.