equal
deleted
inserted
replaced
159 section_items = default_items |
159 section_items = default_items |
160 |
160 |
161 for key, value in section_items: |
161 for key, value in section_items: |
162 # keep a copy of the old value |
162 # keep a copy of the old value |
163 oldvalue = value |
163 oldvalue = value |
|
164 oldsection = section |
164 |
165 |
165 if mapping is not None: |
166 if mapping is not None: |
166 section, key = update_mapping(section, key, mapping) |
167 section, key = update_mapping(section, key, mapping) |
167 |
168 |
168 if section is None and key is None: |
169 if section is None and key is None: |
189 # Only copy the old value to the new conf file if the entry doesn't |
190 # Only copy the old value to the new conf file if the entry doesn't |
190 # exist or if it contains '%SERVICE' |
191 # exist or if it contains '%SERVICE' |
191 if not new.has_option(section, key) or \ |
192 if not new.has_option(section, key) or \ |
192 '%SERVICE' in new.get(section, key): |
193 '%SERVICE' in new.get(section, key): |
193 new.set(section, key, value) |
194 new.set(section, key, value) |
|
195 section = oldsection |
194 |
196 |
195 # copy the old conf file to a backup |
197 # copy the old conf file to a backup |
196 today = datetime.now().strftime("%Y%m%d%H%M%S") |
198 today = datetime.now().strftime("%Y%m%d%H%M%S") |
197 shutil.copy2(old_file, old_file + '.' + today) |
199 shutil.copy2(old_file, old_file + '.' + today) |
198 |
200 |