blob: e8eb3841c5603d5c83026abd245b2eb64b4fc939 [file] [log] [blame]
Georg Brandl392c6fc2008-05-25 07:25:25 +00001:mod:`ConfigParser` --- Configuration file parser
Georg Brandl8ec7f652007-08-15 14:28:01 +00002=================================================
3
Alexandre Vassalottic92fef92008-05-14 22:51:10 +00004.. module:: ConfigParser
Georg Brandl8ec7f652007-08-15 14:28:01 +00005 :synopsis: Configuration file parser.
Alexandre Vassalottie2514c62008-05-14 22:44:22 +00006
Georg Brandl8ec7f652007-08-15 14:28:01 +00007.. moduleauthor:: Ken Manheimer <klm@zope.com>
8.. moduleauthor:: Barry Warsaw <bwarsaw@python.org>
9.. moduleauthor:: Eric S. Raymond <esr@thyrsus.com>
10.. sectionauthor:: Christopher G. Petrilli <petrilli@amber.org>
11
Alexandre Vassalottic92fef92008-05-14 22:51:10 +000012.. note::
Georg Brandl392c6fc2008-05-25 07:25:25 +000013
Georg Brandle92818f2009-01-03 20:47:01 +000014 The :mod:`ConfigParser` module has been renamed to :mod:`configparser` in
15 Python 3.0. The :term:`2to3` tool will automatically adapt imports when
16 converting your sources to 3.0.
Alexandre Vassalottic92fef92008-05-14 22:51:10 +000017
Georg Brandl8ec7f652007-08-15 14:28:01 +000018.. index::
19 pair: .ini; file
20 pair: configuration; file
21 single: ini file
22 single: Windows ini file
23
24This module defines the class :class:`ConfigParser`. The :class:`ConfigParser`
25class implements a basic configuration file parser language which provides a
26structure similar to what you would find on Microsoft Windows INI files. You
27can use this to write Python programs which can be customized by end users
28easily.
29
Georg Brandl16a57f62009-04-27 15:29:09 +000030.. note::
Georg Brandl8ec7f652007-08-15 14:28:01 +000031
Georg Brandl16a57f62009-04-27 15:29:09 +000032 This library does *not* interpret or write the value-type prefixes used in
33 the Windows Registry extended version of INI syntax.
Georg Brandl8ec7f652007-08-15 14:28:01 +000034
Ezio Melotti7f9d2ea2011-04-14 06:53:44 +030035.. seealso::
36
37 Module :mod:`shlex`
38 Support for a creating Unix shell-like mini-languages which can be used
39 as an alternate format for application configuration files.
40
41 Module :mod:`json`
42 The json module implements a subset of JavaScript syntax which can also
43 be used for this purpose.
44
Georg Brandl8ec7f652007-08-15 14:28:01 +000045The configuration file consists of sections, led by a ``[section]`` header and
46followed by ``name: value`` entries, with continuations in the style of
Georg Brandl27f43742008-03-26 09:32:46 +000047:rfc:`822` (see section 3.1.1, "LONG HEADER FIELDS"); ``name=value`` is also
48accepted. Note that leading whitespace is removed from values. The optional
49values can contain format strings which refer to other values in the same
50section, or values in a special ``DEFAULT`` section. Additional defaults can be
51provided on initialization and retrieval. Lines beginning with ``'#'`` or
52``';'`` are ignored and may be used to provide comments.
Georg Brandl8ec7f652007-08-15 14:28:01 +000053
Georg Brandld070cc52010-08-01 21:06:46 +000054Configuration files may include comments, prefixed by specific characters (``#``
55and ``;``). Comments may appear on their own in an otherwise empty line, or may
Fred Drake9a9aa202010-11-09 13:33:21 +000056be entered in lines holding values or section names. In the latter case, they
Georg Brandld070cc52010-08-01 21:06:46 +000057need to be preceded by a whitespace character to be recognized as a comment.
58(For backwards compatibility, only ``;`` starts an inline comment, while ``#``
59does not.)
60
61On top of the core functionality, :class:`SafeConfigParser` supports
62interpolation. This means values can contain format strings which refer to
63other values in the same section, or values in a special ``DEFAULT`` section.
64Additional defaults can be provided on initialization.
65
Georg Brandl8ec7f652007-08-15 14:28:01 +000066For example::
67
68 [My Section]
69 foodir: %(dir)s/whatever
70 dir=frob
Georg Brandl27f43742008-03-26 09:32:46 +000071 long: this value continues
72 in the next line
Georg Brandl8ec7f652007-08-15 14:28:01 +000073
74would resolve the ``%(dir)s`` to the value of ``dir`` (``frob`` in this case).
75All reference expansions are done on demand.
76
77Default values can be specified by passing them into the :class:`ConfigParser`
78constructor as a dictionary. Additional defaults may be passed into the
79:meth:`get` method which will override all others.
80
Georg Brandld7d4fd72009-07-26 14:37:28 +000081Sections are normally stored in a built-in dictionary. An alternative dictionary
Georg Brandl8ec7f652007-08-15 14:28:01 +000082type can be passed to the :class:`ConfigParser` constructor. For example, if a
83dictionary type is passed that sorts its keys, the sections will be sorted on
84write-back, as will be the keys within each section.
85
86
Fred Drakecc43b562010-02-19 05:24:30 +000087.. class:: RawConfigParser([defaults[, dict_type[, allow_no_value]]])
Georg Brandl8ec7f652007-08-15 14:28:01 +000088
89 The basic configuration object. When *defaults* is given, it is initialized
90 into the dictionary of intrinsic defaults. When *dict_type* is given, it will
91 be used to create the dictionary objects for the list of sections, for the
Fred Drakecc43b562010-02-19 05:24:30 +000092 options within a section, and for the default values. When *allow_no_value*
93 is true (default: ``False``), options without values are accepted; the value
94 presented for these is ``None``.
95
96 This class does not
Georg Brandl8ec7f652007-08-15 14:28:01 +000097 support the magical interpolation behavior.
98
99 .. versionadded:: 2.3
100
101 .. versionchanged:: 2.6
102 *dict_type* was added.
103
Raymond Hettingere89b8e92009-03-03 05:00:37 +0000104 .. versionchanged:: 2.7
105 The default *dict_type* is :class:`collections.OrderedDict`.
Fred Drakecc43b562010-02-19 05:24:30 +0000106 *allow_no_value* was added.
Raymond Hettingere89b8e92009-03-03 05:00:37 +0000107
Georg Brandl8ec7f652007-08-15 14:28:01 +0000108
Fred Drakecc43b562010-02-19 05:24:30 +0000109.. class:: ConfigParser([defaults[, dict_type[, allow_no_value]]])
Georg Brandl8ec7f652007-08-15 14:28:01 +0000110
111 Derived class of :class:`RawConfigParser` that implements the magical
112 interpolation feature and adds optional arguments to the :meth:`get` and
113 :meth:`items` methods. The values in *defaults* must be appropriate for the
114 ``%()s`` string interpolation. Note that *__name__* is an intrinsic default;
115 its value is the section name, and will override any value provided in
116 *defaults*.
117
118 All option names used in interpolation will be passed through the
119 :meth:`optionxform` method just like any other option name reference. For
120 example, using the default implementation of :meth:`optionxform` (which converts
121 option names to lower case), the values ``foo %(bar)s`` and ``foo %(BAR)s`` are
122 equivalent.
123
Raymond Hettingere89b8e92009-03-03 05:00:37 +0000124 .. versionadded:: 2.3
125
126 .. versionchanged:: 2.6
127 *dict_type* was added.
128
129 .. versionchanged:: 2.7
130 The default *dict_type* is :class:`collections.OrderedDict`.
Fred Drakecc43b562010-02-19 05:24:30 +0000131 *allow_no_value* was added.
Raymond Hettingere89b8e92009-03-03 05:00:37 +0000132
Georg Brandl8ec7f652007-08-15 14:28:01 +0000133
Fred Drakecc43b562010-02-19 05:24:30 +0000134.. class:: SafeConfigParser([defaults[, dict_type[, allow_no_value]]])
Georg Brandl8ec7f652007-08-15 14:28:01 +0000135
136 Derived class of :class:`ConfigParser` that implements a more-sane variant of
137 the magical interpolation feature. This implementation is more predictable as
138 well. New applications should prefer this version if they don't need to be
139 compatible with older versions of Python.
140
Georg Brandlb19be572007-12-29 10:57:00 +0000141 .. XXX Need to explain what's safer/more predictable about it.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000142
143 .. versionadded:: 2.3
144
Raymond Hettingere89b8e92009-03-03 05:00:37 +0000145 .. versionchanged:: 2.6
146 *dict_type* was added.
147
148 .. versionchanged:: 2.7
149 The default *dict_type* is :class:`collections.OrderedDict`.
Fred Drakecc43b562010-02-19 05:24:30 +0000150 *allow_no_value* was added.
Raymond Hettingere89b8e92009-03-03 05:00:37 +0000151
Georg Brandl8ec7f652007-08-15 14:28:01 +0000152
Georg Brandld070cc52010-08-01 21:06:46 +0000153.. exception:: Error
154
155 Base class for all other configparser exceptions.
156
157
Georg Brandl8ec7f652007-08-15 14:28:01 +0000158.. exception:: NoSectionError
159
160 Exception raised when a specified section is not found.
161
162
163.. exception:: DuplicateSectionError
164
165 Exception raised if :meth:`add_section` is called with the name of a section
166 that is already present.
167
168
169.. exception:: NoOptionError
170
171 Exception raised when a specified option is not found in the specified section.
172
173
174.. exception:: InterpolationError
175
176 Base class for exceptions raised when problems occur performing string
177 interpolation.
178
179
180.. exception:: InterpolationDepthError
181
182 Exception raised when string interpolation cannot be completed because the
183 number of iterations exceeds :const:`MAX_INTERPOLATION_DEPTH`. Subclass of
184 :exc:`InterpolationError`.
185
186
187.. exception:: InterpolationMissingOptionError
188
189 Exception raised when an option referenced from a value does not exist. Subclass
190 of :exc:`InterpolationError`.
191
192 .. versionadded:: 2.3
193
194
195.. exception:: InterpolationSyntaxError
196
197 Exception raised when the source text into which substitutions are made does not
198 conform to the required syntax. Subclass of :exc:`InterpolationError`.
199
200 .. versionadded:: 2.3
201
202
203.. exception:: MissingSectionHeaderError
204
205 Exception raised when attempting to parse a file which has no section headers.
206
207
208.. exception:: ParsingError
209
210 Exception raised when errors occur attempting to parse a file.
211
212
213.. data:: MAX_INTERPOLATION_DEPTH
214
215 The maximum depth for recursive interpolation for :meth:`get` when the *raw*
216 parameter is false. This is relevant only for the :class:`ConfigParser` class.
217
218
219.. seealso::
220
221 Module :mod:`shlex`
222 Support for a creating Unix shell-like mini-languages which can be used as an
223 alternate format for application configuration files.
224
225
226.. _rawconfigparser-objects:
227
228RawConfigParser Objects
229-----------------------
230
231:class:`RawConfigParser` instances have the following methods:
232
233
234.. method:: RawConfigParser.defaults()
235
236 Return a dictionary containing the instance-wide defaults.
237
238
239.. method:: RawConfigParser.sections()
240
241 Return a list of the sections available; ``DEFAULT`` is not included in the
242 list.
243
244
245.. method:: RawConfigParser.add_section(section)
246
247 Add a section named *section* to the instance. If a section by the given name
Facundo Batistab12f0b52008-02-23 12:46:10 +0000248 already exists, :exc:`DuplicateSectionError` is raised. If the name
249 ``DEFAULT`` (or any of it's case-insensitive variants) is passed,
250 :exc:`ValueError` is raised.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000251
252.. method:: RawConfigParser.has_section(section)
253
254 Indicates whether the named section is present in the configuration. The
255 ``DEFAULT`` section is not acknowledged.
256
257
258.. method:: RawConfigParser.options(section)
259
260 Returns a list of options available in the specified *section*.
261
262
263.. method:: RawConfigParser.has_option(section, option)
264
265 If the given section exists, and contains the given option, return
266 :const:`True`; otherwise return :const:`False`.
267
268 .. versionadded:: 1.6
269
270
271.. method:: RawConfigParser.read(filenames)
272
273 Attempt to read and parse a list of filenames, returning a list of filenames
274 which were successfully parsed. If *filenames* is a string or Unicode string,
275 it is treated as a single filename. If a file named in *filenames* cannot be
276 opened, that file will be ignored. This is designed so that you can specify a
277 list of potential configuration file locations (for example, the current
278 directory, the user's home directory, and some system-wide directory), and all
279 existing configuration files in the list will be read. If none of the named
280 files exist, the :class:`ConfigParser` instance will contain an empty dataset.
281 An application which requires initial values to be loaded from a file should
282 load the required file or files using :meth:`readfp` before calling :meth:`read`
283 for any optional files::
284
Benjamin Petersona7b55a32009-02-20 03:31:23 +0000285 import ConfigParser, os
Georg Brandl8ec7f652007-08-15 14:28:01 +0000286
Georg Brandl392c6fc2008-05-25 07:25:25 +0000287 config = ConfigParser.ConfigParser()
Georg Brandl8ec7f652007-08-15 14:28:01 +0000288 config.readfp(open('defaults.cfg'))
289 config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
290
291 .. versionchanged:: 2.4
292 Returns list of successfully parsed filenames.
293
294
295.. method:: RawConfigParser.readfp(fp[, filename])
296
297 Read and parse configuration data from the file or file-like object in *fp*
298 (only the :meth:`readline` method is used). If *filename* is omitted and *fp*
299 has a :attr:`name` attribute, that is used for *filename*; the default is
300 ``<???>``.
301
302
303.. method:: RawConfigParser.get(section, option)
304
305 Get an *option* value for the named *section*.
306
307
308.. method:: RawConfigParser.getint(section, option)
309
310 A convenience method which coerces the *option* in the specified *section* to an
311 integer.
312
313
314.. method:: RawConfigParser.getfloat(section, option)
315
316 A convenience method which coerces the *option* in the specified *section* to a
317 floating point number.
318
319
320.. method:: RawConfigParser.getboolean(section, option)
321
322 A convenience method which coerces the *option* in the specified *section* to a
323 Boolean value. Note that the accepted values for the option are ``"1"``,
324 ``"yes"``, ``"true"``, and ``"on"``, which cause this method to return ``True``,
325 and ``"0"``, ``"no"``, ``"false"``, and ``"off"``, which cause it to return
326 ``False``. These string values are checked in a case-insensitive manner. Any
327 other value will cause it to raise :exc:`ValueError`.
328
329
330.. method:: RawConfigParser.items(section)
331
332 Return a list of ``(name, value)`` pairs for each option in the given *section*.
333
334
335.. method:: RawConfigParser.set(section, option, value)
336
337 If the given section exists, set the given option to the specified value;
338 otherwise raise :exc:`NoSectionError`. While it is possible to use
339 :class:`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters set to
340 true) for *internal* storage of non-string values, full functionality (including
341 interpolation and output to files) can only be achieved using string values.
342
343 .. versionadded:: 1.6
344
345
346.. method:: RawConfigParser.write(fileobject)
347
348 Write a representation of the configuration to the specified file object. This
349 representation can be parsed by a future :meth:`read` call.
350
351 .. versionadded:: 1.6
352
353
354.. method:: RawConfigParser.remove_option(section, option)
355
356 Remove the specified *option* from the specified *section*. If the section does
357 not exist, raise :exc:`NoSectionError`. If the option existed to be removed,
358 return :const:`True`; otherwise return :const:`False`.
359
360 .. versionadded:: 1.6
361
362
363.. method:: RawConfigParser.remove_section(section)
364
365 Remove the specified *section* from the configuration. If the section in fact
366 existed, return ``True``. Otherwise return ``False``.
367
368
369.. method:: RawConfigParser.optionxform(option)
370
Georg Brandldc020522009-10-23 08:14:44 +0000371 Transforms the option name *option* as found in an input file or as passed in
372 by client code to the form that should be used in the internal structures.
373 The default implementation returns a lower-case version of *option*;
374 subclasses may override this or client code can set an attribute of this name
375 on instances to affect this behavior.
376
377 You don't necessarily need to subclass a ConfigParser to use this method, you
378 can also re-set it on an instance, to a function that takes a string
379 argument. Setting it to ``str``, for example, would make option names case
380 sensitive::
381
382 cfgparser = ConfigParser()
383 ...
384 cfgparser.optionxform = str
Georg Brandl8ec7f652007-08-15 14:28:01 +0000385
Fred Draked617cba2009-10-23 13:04:51 +0000386 Note that when reading configuration files, whitespace around the
Georg Brandl5460ff92009-10-24 10:04:19 +0000387 option names are stripped before :meth:`optionxform` is called.
Fred Draked617cba2009-10-23 13:04:51 +0000388
Georg Brandl8ec7f652007-08-15 14:28:01 +0000389
390.. _configparser-objects:
391
392ConfigParser Objects
393--------------------
394
395The :class:`ConfigParser` class extends some methods of the
396:class:`RawConfigParser` interface, adding some optional arguments.
397
398
399.. method:: ConfigParser.get(section, option[, raw[, vars]])
400
Georg Brandld070cc52010-08-01 21:06:46 +0000401 Get an *option* value for the named *section*. If *vars* is provided, it
402 must be a dictionary. The *option* is looked up in *vars* (if provided),
403 *section*, and in *defaults* in that order.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000404
Georg Brandld070cc52010-08-01 21:06:46 +0000405 All the ``'%'`` interpolations are expanded in the return values, unless the
406 *raw* argument is true. Values for interpolation keys are looked up in the
407 same manner as the option.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000408
409.. method:: ConfigParser.items(section[, raw[, vars]])
410
411 Return a list of ``(name, value)`` pairs for each option in the given *section*.
412 Optional arguments have the same meaning as for the :meth:`get` method.
413
414 .. versionadded:: 2.3
415
416
417.. _safeconfigparser-objects:
418
419SafeConfigParser Objects
420------------------------
421
422The :class:`SafeConfigParser` class implements the same extended interface as
423:class:`ConfigParser`, with the following addition:
424
425
426.. method:: SafeConfigParser.set(section, option, value)
427
428 If the given section exists, set the given option to the specified value;
429 otherwise raise :exc:`NoSectionError`. *value* must be a string (:class:`str`
430 or :class:`unicode`); if not, :exc:`TypeError` is raised.
431
432 .. versionadded:: 2.4
433
Georg Brandl430e3622007-11-29 17:02:34 +0000434
435Examples
436--------
437
438An example of writing to a configuration file::
439
Georg Brandl392c6fc2008-05-25 07:25:25 +0000440 import ConfigParser
Georg Brandl430e3622007-11-29 17:02:34 +0000441
Georg Brandl392c6fc2008-05-25 07:25:25 +0000442 config = ConfigParser.RawConfigParser()
443
Georg Brandl430e3622007-11-29 17:02:34 +0000444 # When adding sections or items, add them in the reverse order of
445 # how you want them to be displayed in the actual file.
446 # In addition, please note that using RawConfigParser's and the raw
447 # mode of ConfigParser's respective set functions, you can assign
448 # non-string values to keys internally, but will receive an error
449 # when attempting to write to a file or when you get it in non-raw
450 # mode. SafeConfigParser does not allow such assignments to take place.
451 config.add_section('Section1')
452 config.set('Section1', 'int', '15')
453 config.set('Section1', 'bool', 'true')
454 config.set('Section1', 'float', '3.1415')
455 config.set('Section1', 'baz', 'fun')
456 config.set('Section1', 'bar', 'Python')
457 config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
Georg Brandl392c6fc2008-05-25 07:25:25 +0000458
Georg Brandl430e3622007-11-29 17:02:34 +0000459 # Writing our configuration file to 'example.cfg'
460 with open('example.cfg', 'wb') as configfile:
461 config.write(configfile)
462
463An example of reading the configuration file again::
464
Georg Brandl392c6fc2008-05-25 07:25:25 +0000465 import ConfigParser
Georg Brandl430e3622007-11-29 17:02:34 +0000466
Georg Brandl392c6fc2008-05-25 07:25:25 +0000467 config = ConfigParser.RawConfigParser()
Georg Brandl430e3622007-11-29 17:02:34 +0000468 config.read('example.cfg')
469
470 # getfloat() raises an exception if the value is not a float
471 # getint() and getboolean() also do this for their respective types
472 float = config.getfloat('Section1', 'float')
473 int = config.getint('Section1', 'int')
474 print float + int
475
476 # Notice that the next output does not interpolate '%(bar)s' or '%(baz)s'.
477 # This is because we are using a RawConfigParser().
478 if config.getboolean('Section1', 'bool'):
479 print config.get('Section1', 'foo')
480
481To get interpolation, you will need to use a :class:`ConfigParser` or
482:class:`SafeConfigParser`::
483
Georg Brandl392c6fc2008-05-25 07:25:25 +0000484 import ConfigParser
Georg Brandl430e3622007-11-29 17:02:34 +0000485
Georg Brandl392c6fc2008-05-25 07:25:25 +0000486 config = ConfigParser.ConfigParser()
Georg Brandl430e3622007-11-29 17:02:34 +0000487 config.read('example.cfg')
488
489 # Set the third, optional argument of get to 1 if you wish to use raw mode.
490 print config.get('Section1', 'foo', 0) # -> "Python is fun!"
491 print config.get('Section1', 'foo', 1) # -> "%(bar)s is %(baz)s!"
492
493 # The optional fourth argument is a dict with members that will take
494 # precedence in interpolation.
495 print config.get('Section1', 'foo', 0, {'bar': 'Documentation',
496 'baz': 'evil'})
497
Georg Brandl392c6fc2008-05-25 07:25:25 +0000498Defaults are available in all three types of ConfigParsers. They are used in
Georg Brandl430e3622007-11-29 17:02:34 +0000499interpolation if an option used is not defined elsewhere. ::
500
Georg Brandl392c6fc2008-05-25 07:25:25 +0000501 import ConfigParser
Georg Brandl430e3622007-11-29 17:02:34 +0000502
503 # New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each
Georg Brandl392c6fc2008-05-25 07:25:25 +0000504 config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
Georg Brandl430e3622007-11-29 17:02:34 +0000505 config.read('example.cfg')
Georg Brandl392c6fc2008-05-25 07:25:25 +0000506
Georg Brandl430e3622007-11-29 17:02:34 +0000507 print config.get('Section1', 'foo') # -> "Python is fun!"
508 config.remove_option('Section1', 'bar')
509 config.remove_option('Section1', 'baz')
510 print config.get('Section1', 'foo') # -> "Life is hard!"
511
512The function ``opt_move`` below can be used to move options between sections::
513
514 def opt_move(config, section1, section2, option):
515 try:
516 config.set(section2, option, config.get(section1, option, 1))
Georg Brandl392c6fc2008-05-25 07:25:25 +0000517 except ConfigParser.NoSectionError:
Georg Brandl430e3622007-11-29 17:02:34 +0000518 # Create non-existent section
519 config.add_section(section2)
520 opt_move(config, section1, section2, option)
Georg Brandl960b1862008-01-21 16:28:13 +0000521 else:
522 config.remove_option(section1, option)
Fred Drakecc43b562010-02-19 05:24:30 +0000523
524Some configuration files are known to include settings without values, but which
525otherwise conform to the syntax supported by :mod:`ConfigParser`. The
526*allow_no_value* parameter to the constructor can be used to indicate that such
527values should be accepted:
528
529.. doctest::
530
531 >>> import ConfigParser
532 >>> import io
533
534 >>> sample_config = """
535 ... [mysqld]
536 ... user = mysql
537 ... pid-file = /var/run/mysqld/mysqld.pid
538 ... skip-external-locking
539 ... old_passwords = 1
540 ... skip-bdb
541 ... skip-innodb
542 ... """
543 >>> config = ConfigParser.RawConfigParser(allow_no_value=True)
544 >>> config.readfp(io.BytesIO(sample_config))
545
546 >>> # Settings with values are treated as before:
547 >>> config.get("mysqld", "user")
548 'mysql'
549
550 >>> # Settings without values provide None:
551 >>> config.get("mysqld", "skip-bdb")
552
553 >>> # Settings which aren't specified still raise an error:
554 >>> config.get("mysqld", "does-not-exist")
555 Traceback (most recent call last):
556 ...
557 ConfigParser.NoOptionError: No option 'does-not-exist' in section: 'mysqld'