|
From: Stewart M. <mi...@ya...> - 2006-04-13 02:02:14
|
Hi Fuzzy, I have a question about round-tripping in ConfigObj, as per
the "product description".
My expectation was that if I parse an input file with configobj and
then write back to the file with configobj, my comments would be
retained. But it seems that they are not.
>>> from configobj import ConfigObj
>>> text = open('pwadmin.ini').read()
>>> text
'#initial settings for pwadmin.py\npwProjectHome =
C:\\Programs\\PipeWorksB\\lib
\\python\\admin'
>>> attributes = ConfigObj('pwadmin.ini')
>>> attributes
{'pwProjectHome': 'C:\\Programs\\PipeWorksB\\lib\\python\\admin'}
>>> attributes.initial_comment
['#initial settings for pwadmin.py']
>>> config = ConfigObj(attributes)
>>> config.filename = 'pwadmin.out.ini'
>>> config.write()
>>> text = open('pwadmin.out.ini').read()
>>> text
'pwProjectHome = C:\\Programs\\PipeWorksB\\lib\\python\\admin'
>>>
It looks as though, if I want comments retained in my settings file,
I will have to manually write out initial comments, then section
comments (if any), then final comments. Is that correct? I don't
see this aspect explicitly addressed in the documentation.
thanks
Stewart in Calgary
Stewart Midwinter
Please respond to st...@mi...
Visit http://midwinter.ca or http://midtoad.org
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|