Skip to content
This repository
Browse code

normalize option names before merging configs to avoid configobj brai…

…ndamage

renaming an option after merging leaves the original option intact.  This
can leave two options of the same name when generating a config file which
renders a config unreadable by ConfigObj in the future due to a
'Duplicate keyword' error.
  • Loading branch information...
commit 024c271cc256ed560615a91dc97b5e8d25017bd6 1 parent 0b5fef3
Andrew Garner authored October 15, 2012

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  holland/core/config/config.py
3  holland/core/config/config.py
@@ -106,6 +106,7 @@ class BackupConfig(BaseConfig):
106 106
     def __init__(self, path):
107 107
         BaseConfig.__init__(self, None)
108 108
         basecfg = BaseConfig(path)
  109
+        basecfg.walk(self._canonicalize, call_on_sections=True)
109 110
         provider = basecfg.lookup('holland:backup.plugin')
110 111
         if provider:
111 112
             try:
@@ -113,13 +114,13 @@ def __init__(self, path):
113 114
                 providerpath = os.path.join(configbase, 'providers', provider)
114 115
                 providerpath += CONFIG_SUFFIX
115 116
                 providercfg = BaseConfig(providerpath)
  117
+                providercfg.walk(self._canonicalize, call_on_sections=True)
116 118
                 self.merge(providercfg)
117 119
             except IOError, ex:
118 120
                 LOGGER.warning("Failed to load config for provider %r (%s)" %
119 121
                                     (provider, ex))
120 122
         self.merge(basecfg)
121 123
         self.filename = basecfg.filename
122  
-        self.walk(self._canonicalize, call_on_sections=True)
123 124
 
124 125
 
125 126
 class GlobalConfig(BaseConfig):

0 notes on commit 024c271

Please sign in to comment.
Something went wrong with that request. Please try again.