#!/usr/bin/env python import os, sys, shutil base_path = os.path.dirname(os.path.realpath(__file__)) usage = "usage: update_version current_version new_version \ne.g.: update_version 2.0.0 2.0.1" files = ["org.wesnoth.dependencies.feature/feature.xml", "org.wesnoth.feature/category.xml", "org.wesnoth.feature/feature.xml", "org.wesnoth.ui/META-INF/MANIFEST.MF","org.wesnoth/META-INF/MANIFEST.MF", "org.wesnoth/org.wesnoth.product"] if len(sys.argv) < 3: print usage else: print "Replacing version ", sys.argv[1], " with ", sys.argv[2], "..." stext = sys.argv[1] + ".qualifier" rtext = sys.argv[2] + ".qualifier" for file in files: sourcePath = os.path.join(os.path.join(base_path, ".."), file) targetPath = os.path.join(os.path.join(base_path, ".."), file + ".tmp") print "Processing: ", sourcePath input = open(sourcePath) output = open(targetPath, "w") for s in input.xreadlines(): output.write(s.replace(stext, rtext)) input.close() output.close() shutil.move (targetPath, sourcePath)