This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients gvanrossum, kernc, lukasz.langa, martin.panter, paul.moore, serhiy.storchaka, terry.reedy, tshepang
Date 2014-09-15.19:41:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410810078.41.0.0909271723289.issue22253@psf.upfronthosting.co.za>
In-reply-to
Content
I read the rsyncd.conf doc at http://linux.die.net/man/5/rsyncd.conf (linked from the StackOverflow question).  These files are not .ini files. However, I believe the parsing rules are mostly compatible with RawConfigParser, or could be made so by using existing customization options, including subclassing.

The sectionless options are called 'global options' for one of two different reasons.  Some, selected from a predefined list of startup options, act as if they were in a [STARTUP] section.  Others, selected from a predefined list of module options, act as if they were in a [DEFAULT] section. The latter provide alternate default value for options in the various [<module>] sections.

We clearly should not directly support the specialized rules of rsyncd.conf.  But if, as kernc requests, RawConfigParser gathered sectionless options into a '' section, users could probably work with these files.  The details would be up to them, or a config_unix module writer.  The same comment applies to other files, including .ini files with sectionless options.

Łukasz, the only one bikeshedding '' is you.  I do not see any need for a new API and I think it just confuses this issue.  Reading and writing sectionless options via a '' section should be sufficient to work with .ini files.

To me, the remaining question is whether to retain configparser.MissingSectionHeaderError.  The problem with piggy-backing its optional use on the 'strict' parameter is that someone might want to reject duplicates while reading sectionless options.  But it ia a plausible idea.

As an aside, the documentation for MissingSectionHeaderError is currently a bit confused.  The docstring correctly says "Raised when a key-value pair is found before any section header."  The doc incorrectly says "Exception raised when attempting to parse a file which has no section headers."  I tested and it is indeed raised even when there is a section header after an initial option line.  The exception message is also wrong: "File contains no section headers."  The latter two should really say that the files does not *start* with a section header (ignoring comment lines), or use the wording of the docstring.
History
Date User Action Args
2014-09-15 19:41:18terry.reedysetrecipients: + terry.reedy, gvanrossum, paul.moore, lukasz.langa, tshepang, martin.panter, serhiy.storchaka, kernc
2014-09-15 19:41:18terry.reedysetmessageid: <1410810078.41.0.0909271723289.issue22253@psf.upfronthosting.co.za>
2014-09-15 19:41:18terry.reedylinkissue22253 messages
2014-09-15 19:41:18terry.reedycreate