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 <rep...@bugs.python.org>
<http://bugs.python.org/issue21329>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to