|
From: Fuzzyman <fuz...@vo...> - 2006-03-17 12:04:27
|
Louis Cordier wrote: > > On Fri, 17 Mar 2006, Fuzzyman wrote: >> Can you explain to me what this actually does (sorry for my ignorance). >> >> You want to create a default config file from a configspec. You want >> to copy the comments from the configspec *into* the config file when >> this is done ? > > Yes, retaining the layout of the configspec. > >> You have attempted to do this with walk, but walk *doesn't* honour >> the order of the configspec, so you have implemented an alternative. > > My main aim wasn't to re-implement walk. In some case I have seen > walk honour the order and in others not. (not too sure why) > Right - I think that where ``walk`` doesn't honour order that is a bug and I will fix it. Thanks for your example illustrating this. > I simply tried to cheat write() into writing a config-file that the > validator populated with default values. I used walk to recursively > empty each section's defaults member (section.defaults = []). > I noticed that write didn't write those entries that was in .defaults > so I removed them all. ;) > Ahh... I forgot that normally ``write`` doesn't write out unchanged default values. Instead of a ``copy_comments`` option we need a copy mode. How about an optional ``copy`` keyword to ``validate`` ? If this is set then comments are copied and none of the values supplied from the configspec are marked as default - in this case ``write`` should behave as expected. > [snip..] All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml |