diff options
author | PJ Eby <distutils-sig@python.org> | 2005-07-08 15:50:32 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-07-08 15:50:32 +0000 |
commit | d798d6943f81d938581c37b431b141b013678021 (patch) | |
tree | eafe890497eed2a3564f908e5f3096aade320798 /setuptools/command/setopt.py | |
parent | 1d7b59f5172a215ad9961e2eb8bbd1756b941a5f (diff) | |
download | external_python_setuptools-d798d6943f81d938581c37b431b141b013678021.tar.gz external_python_setuptools-d798d6943f81d938581c37b431b141b013678021.tar.bz2 external_python_setuptools-d798d6943f81d938581c37b431b141b013678021.zip |
Delete empty sections when their last option is deleted.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041099
Diffstat (limited to 'setuptools/command/setopt.py')
-rwxr-xr-x | setuptools/command/setopt.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/setuptools/command/setopt.py b/setuptools/command/setopt.py index 3af0753f..dbf3a94e 100755 --- a/setuptools/command/setopt.py +++ b/setuptools/command/setopt.py @@ -51,10 +51,9 @@ def edit_config(filename, settings, dry_run=False): log.debug("Reading configuration from %s", filename) opts = RawConfigParser() opts.read([filename]) - for section, options in settings.items(): if options is None: - log.debug("Deleting section [%s] from %s", section, filename) + log.info("Deleting section [%s] from %s", section, filename) opts.remove_section(section) else: if not opts.has_section(section): @@ -66,6 +65,10 @@ def edit_config(filename, settings, dry_run=False): section, option, filename ) opts.remove_option(section,option) + if not opts.options(section): + log.info("Deleting empty [%s] section from %s", + section, filename) + opts.remove_section(section) else: log.debug( "Setting %s.%s to %r in %s", @@ -75,10 +78,7 @@ def edit_config(filename, settings, dry_run=False): log.info("Writing %s", filename) if not dry_run: - f = open(filename,'w') - opts.write(f) - f.close() - + f = open(filename,'w'); opts.write(f); f.close() class option_base(Command): """Abstract base class for commands that mess with config files""" |