Terry J. Reedy added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22253>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to