[New-bugs-announce] [issue21329] configparser can't parse MySQL style config

Daniël van Eeden report at bugs.python.org
Tue Apr 22 17:27:33 CEST 2014


New submission from Daniël van Eeden:

With Python 2.7 the ConfigParser was enriched with the allow_no_value option which resulted in a much more usable configparser for MySQL configs.

It can now parse configs like this:
[mysqld]
log_bin
innodb_file_per_table
innodb_io_capacity=800

However it can't parse this config:
[mysqld]
log_bin
innodb_file_per_table
innodb_io_capacity=800
replicate-do-db="test1"
replicate-do-db="test2"

A comma separated config might have been better, but that's not the case with many MySQL config (and probably doesn't even work for this option).

>From http://dev.mysql.com/doc/refman/5.6/en/replication-options-slave.html#option_mysqld_replicate-do-db
"To specify more than one database, use this option multiple times, once for each database"


The dict/orderedDict which is used by configparser doesn't easlily allow to store a config like this.

The MySQL config file is used as an example in the documentation:
https://docs.python.org/3/library/configparser.html#customizing-parser-behaviour

This could be solved by having a list of values if the key exists more than once.

Python 3 improves this a bit by giving a DuplicateOptionError by default.

----------
components: Library (Lib)
files: demo.py
messages: 217012
nosy: dveeden
priority: normal
severity: normal
status: open
title: configparser can't parse MySQL style config
versions: Python 3.4
Added file: http://bugs.python.org/file35001/demo.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21329>
_______________________________________


More information about the New-bugs-announce mailing list