Changeset 4433
- Timestamp:
- 04/04/09 22:39:48 (4 years ago)
- Files:
-
- 1 modified
-
trunk/umit/merger/merge_ini.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/umit/merger/merge_ini.py
r4417 r4433 3 3 import ConfigParser 4 4 5 def merge( old_file, new_file):5 def merge(from_file, to_file): 6 6 """ 7 @ old_file: Path to a supposed older ini file8 @ new_file: Path to a supposed newer ini file7 @from_file: Path to a supposed newer ini file 8 @to_file: Path to a supposed older ini file 9 9 @return true or false 10 10 """ 11 if not os.path.exists( old_file) or not os.path.exists(new_file):11 if not os.path.exists(from_file) or not os.path.exists(to_file): 12 12 return False 13 13 14 # Backup old file15 shutil.copyfile( old_file, old_file + '.bak')14 # Backup the destination 15 shutil.copyfile(to_file, to_file + '.bak') 16 16 17 17 # Read new file 18 18 config_new = ConfigParser.RawConfigParser() 19 config_new.read( new_file)19 config_new.read(from_file) 20 20 21 21 # Read old file 22 22 config = ConfigParser.RawConfigParser() 23 config.read( old_file)23 config.read(to_file) 24 24 25 25 # Merge files … … 36 36 37 37 # Write back the merged configuration 38 f = open( old_file, 'wb')38 f = open(to_file, 'wb') 39 39 config.write(f) 40 40
