I'm using configparser
to read configuration for a backup-system.
one of the options (the output path) often includes the section-name itself.
[DEFAULT]
compression=gzip
[foo]
output=/Backups/foo/
[pizza]
output=/BigDisk/Backups/
[bar]
output=/Backups/bar/
Now I would like to get rid manually appending the section name, and instead would like to use string interpolation. Something like the following:
[DEFAULT]
compression=gzip
output=/Backups/%(SECTION)s/
[foo]
[pizza]
output=/BigDisk/Backups/
[bar]
Unfortunately i haven't found the variable-name that would expand to the section name yet (it's obviously not SECTION
).
Is it possible at all (ideally without having to build my own ConfigParser sub-class)?
An ugly workaround would be to add an option append_section_name
(and set it to yes
in the DEFAULT
section and to no
in the pizza
section) and manually do the interpolation. I'd rather not...