|
From: Michael F. <fuz...@vo...> - 2006-09-10 17:13:37
|
Tomi Kyöstilä wrote: > Michael Foord wrote: >> Tomi Kyöstilä wrote: >>> Hi! >>> >>> Is it possible to spread lists over multiple lines in ConfigObj? >>> >>> For example, this one-line list >>> >>> asd = foo, bar, baz >>> >>> would be written as >>> >>> asd = foo, >>> bar, >>> baz >>> >>> When I try that, I get a parse error. It would make managing the >>> config files easier when it contains long lists. >> This feature would be very cool, but also quite tricky to implement. :-) >> >> If you are able to do it without making the parser even harder to >> read, I would welcome the patch... > So I've put together a patch in the last four hours and it works well > enough for my needs. I've made just a few test cases so there might > very well be something wrong with it that I haven't thought of. Great - you've even included tests. :-) I'll have a play with it and aim to include it in the next release. > It doesn't work with unrepr mode (I don't really need that feature, I > just tried this with it), but is it even possible to change the > parsing in that mode since it uses the compiler package? > In order to be a valid list it would have to start with [ and end with ]. I *think* that multiline parsing is done before a line is handled to unrepr; so it might be possible to make it work. I'll have a look. > I've attached the patch to this message (don't know if attachments are > allowed) and you can also get the patch from > http://fout.dy.fi/~tomik/configobj-multiline_lists.patch for now. > Fuzzyman, do you want me to upload it to SourceForge? I hesitated > because the patch area seems a bit empty at the moment :). No, posting here is fine. > > Please let me know if you find something wrong with it. I have to update Movable Python docs first, and then I am on to ConfigObj. I will certainly give you feedback. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > > -- > Tomi Kyöstilä > >> >> Fuzzyman >> http://www.voidspace.org.uk/python/index.shtml >> >>> >>> -- >>> Tomi Kyöstilä > ------------------------------------------------------------------------ > > |