equal
deleted
inserted
replaced
173 section_items = default_items |
173 section_items = default_items |
174 |
174 |
175 for key, value in section_items: |
175 for key, value in section_items: |
176 # keep a copy of the old value |
176 # keep a copy of the old value |
177 oldvalue = value |
177 oldvalue = value |
|
178 oldsection = section |
178 |
179 |
179 if mapping is not None: |
180 if mapping is not None: |
180 section, key = update_mapping(section, key, mapping) |
181 section, key = update_mapping(section, key, mapping) |
181 |
182 |
182 if section is None and key is None: |
183 if section is None and key is None: |
203 # Only copy the old value to the new conf file if the entry doesn't |
204 # Only copy the old value to the new conf file if the entry doesn't |
204 # exist or if it contains '%SERVICE' |
205 # exist or if it contains '%SERVICE' |
205 if not new.has_option(section, key) or \ |
206 if not new.has_option(section, key) or \ |
206 '%SERVICE' in new.get(section, key): |
207 '%SERVICE' in new.get(section, key): |
207 new.set(section, key, value) |
208 new.set(section, key, value) |
|
209 section = oldsection |
208 |
210 |
209 # copy the old conf file to a backup |
211 # copy the old conf file to a backup |
210 today = datetime.now().strftime("%Y%m%d%H%M%S") |
212 today = datetime.now().strftime("%Y%m%d%H%M%S") |
211 shutil.copy2(old_file, old_file + '.' + today) |
213 shutil.copy2(old_file, old_file + '.' + today) |
212 |
214 |