ConfigUpdater

The sole purpose of ConfigUpdater is to easily update an INI config file with no changes to the original file except the intended ones. This means comments, the ordering of sections and key/value pairs as well as their case are kept as in the original file. Thus ConfigUpdater provides complementary functionality to Python’s ConfigParser, which is primarily meant for reading config files and writing new ones. Read more on how to use ConfigUpdater in the usage page.

Features

The key differences to ConfigParser are:

  • minimally invasive changes in the updated configuration file,

  • proper handling of comments,

  • only a single config file can be updated at a time,

  • the original case of sections and keys is kept,

  • control over the position of a new section/key.

The following features are deliberately not implemented:

  • interpolation of values,

  • propagation of parameters from the default section,

  • conversion of values,

  • passing key/value pairs with the defaults argument,

  • non-strict mode allowing duplicate sections and keys.

Note

ConfigUpdater started out as a helper for PyScaffold, which still uses it to update the setup.cfg of existing projects. Since then it has become a useful tool in its own right for everyone who needs to change configuration files programmatically without losing the comments and formatting that humans put into them.

Contents

Indices and tables