Changeset e60c643 in trunk
- Timestamp:
- 2020-11-18T15:57:38Z (5 years ago)
- Branches:
- master
- Children:
- aedac9d
- Parents:
- dc611bf
- Location:
- src/allmydata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/test/test_configutil.py ¶
rdc611bf re60c643 16 16 import os.path 17 17 18 from twisted.python.filepath import ( 19 FilePath, 20 ) 18 21 from twisted.trial import unittest 19 22 … … 56 59 # test that set_config can mutate an existing option 57 60 configutil.set_config(config, "node", "nickname", "Alice!") 58 configutil.write_config( tahoe_cfg, config)61 configutil.write_config(FilePath(tahoe_cfg), config) 59 62 60 63 config = configutil.get_config(tahoe_cfg) … … 64 67 descriptor = "Twas brillig, and the slithy toves Did gyre and gimble in the wabe" 65 68 configutil.set_config(config, "node", "descriptor", descriptor) 66 configutil.write_config( tahoe_cfg, config)69 configutil.write_config(FilePath(tahoe_cfg), config) 67 70 68 71 config = configutil.get_config(tahoe_cfg) -
TabularUnified src/allmydata/util/configutil.py ¶
rdc611bf re60c643 60 60 61 61 def write_config(tahoe_cfg, config): 62 with open(tahoe_cfg, "w") as f: 63 config.write(f) 62 """ 63 Write a configuration to a file. 64 65 :param FilePath tahoe_cfg: The path to which to write the config. 66 67 :param ConfigParser config: The configuration to write. 68 69 :return: ``None`` 70 """ 71 tmp = tahoe_cfg.temporarySibling() 72 # FilePath.open can only open files in binary mode which does not work 73 # with ConfigParser.write. 74 with open(tmp.path, "wt") as fp: 75 config.write(fp) 76 tmp.moveTo(tahoe_cfg) 64 77 65 78 def validate_config(fname, cfg, valid_config):
Note: See TracChangeset
for help on using the changeset viewer.