I don't think you need to worry about scalability here. I'd say it literally takes more time to render the sed output in your console than it does to search that file a hundred times. Not because sed is special (though I'm sure it is efficient) but because searching a text file is just that cheap at this file size.
Anyway something like this should help some. This is a node.js script, because I am not super familiar with python or the like. If you are/have used sed then you should be able to use this fine. Just install node, save it as dfinitmigrate.js in the init folder, and run 'node dfinitmigrate.js OLDINIT.txt NEWINIT.txt' in the console in that folder - for each setting in the new init, it will check the old init file and copy its line if it has a different value for it. It will not copy old settings if they don't even have a line in the new file, though.
var fs = require('fs');
//node dfinitmigrate.js OLDINIT.txt NEWINIT.txt
var len = process.argv.length;
var oldc = process.argv[len-2];//second to last argument
var newc = process.argv[len-1];//last argument
var OLD_CONF = fs.readFileSync(oldc).toString();
var NEW_CONF = fs.readFileSync(newc).toString();
var regex = /^\[([\w]*):([\w]*)\]/gm
//var arr = regex.exec(NEW_CONF);//.match(regex);
var OLD_CONF_TABLE = [];
var NEW_CONF_TABLE = [];
var myArray;
while ((myArray = regex.exec(OLD_CONF)) !== null) {
OLD_CONF_TABLE[OLD_CONF_TABLE.length] =
{
'full':myArray[0],//'[SOUND:NO]',
'key':myArray[1],//'SOUND',
'val':myArray[2],//'NO',
};
}
regex.lastIndex = 0;
while ((myArray = regex.exec(NEW_CONF)) !== null) {
NEW_CONF_TABLE[NEW_CONF_TABLE.length] =
{
'full':myArray[0],
'key':myArray[1],
'val':myArray[2],
};
}
console.log(OLD_CONF_TABLE.length);
console.log(NEW_CONF_TABLE.length);
function oldhaskey(key) {
var length = OLD_CONF_TABLE.length;
for(var i = 0; i < length; i++) {
if(OLD_CONF_TABLE[i].key == key) return i;
}
return -1;
}
var new_copy = NEW_CONF;
for(var i = 0; i < NEW_CONF_TABLE.length; i++)
{
var old = oldhaskey(NEW_CONF_TABLE[i].key);
if(old != -1)
{
if(NEW_CONF_TABLE[i].full != OLD_CONF_TABLE[i].full)
{
new_copy = new_copy.replace(NEW_CONF_TABLE[i].full,OLD_CONF_TABLE[i].full);
console.log('migrating value of '+OLD_CONF_TABLE[i].full);
}
}
}
fs.writeFileSync('./MIGRATE.txt', new_copy);