Message112409
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) |
|
Date |
User |
Action |
Args |
2010-08-02 00:31:17 | lukasz.langa | set | recipients:
+ lukasz.langa |
2010-08-02 00:31:16 | lukasz.langa | set | messageid: <1280709076.78.0.0624402875371.issue9452@psf.upfronthosting.co.za> |
2010-08-02 00:31:14 | lukasz.langa | link | issue9452 messages |
2010-08-02 00:31:11 | lukasz.langa | create | |
|