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 lukasz.langa
Recipients lukasz.langa
Date 2010-08-02.00:31:11
SpamBayes Score 1.4000798e-08
Marked as misclassified No
Message-id <1280709076.78.0.0624402875371.issue9452@psf.upfronthosting.co.za>
In-reply-to
Content
Overview
--------

It's a fairly common need in configuration parsing to take configuration from a string or a Python data structure (most commonly, a dictionary). The attached patch introduces two new methods to RawConfigParser that serve this purpose: readstring and readdict. In the process, two behavioral bugs were detected and fixed.

Detailed information about the patch
------------------------------------
Source changes:
* added readstring and readdict methods
* fixed a bug in SafeConfigParser.set when setting a None value would raise an exception (the code tried to remove interpolation escapes from None)
* added a new exception DuplicateOptionError, raised when during parsing a single file, string or a dictionary the same option occurs twice. This catches mispellings and case-sensitivity errors (parsers are by default case-insensitive in regard to options).
* added checking for option duplicates described above in _read

Test changes:
* self.fromstring is using readstring now
* self.cf removed because it was bad design, now config parser instances are explicit everywhere
  ** changed definition of get_error and parse_error
* split test_basic into two parts: config parser building and the actual test
  ** introduced config parser built from the dictionary
* added a duplicate option checking case for string and dictionary based reading

Documentation changes:
* documented readstring and readdict
* documented DuplicateOptionError
* explicit remark about the case-insensitivity
* corrected remark about leading whitespace being removed from values (also trailing whitespace is, and for keys as well)
History
Date User Action Args
2010-08-02 00:31:17lukasz.langasetrecipients: + lukasz.langa
2010-08-02 00:31:16lukasz.langasetmessageid: <1280709076.78.0.0624402875371.issue9452@psf.upfronthosting.co.za>
2010-08-02 00:31:14lukasz.langalinkissue9452 messages
2010-08-02 00:31:11lukasz.langacreate