diff --git a/changelog.md b/changelog.md index 543e1333051..6c338b9d231 100644 --- a/changelog.md +++ b/changelog.md @@ -53,7 +53,8 @@ * Fix infinite recursion in SUF with [hides] and [filter_vision]. (Issue#1389) ### Miscellaneous and bug fixes * Fixed :droid's arguments not all being optional (Issue#4308) - * Ported the "expand-terrain-macros", "wmlflip" and "wmlparser" tools to Python 3 + * Ported the "expand-terrain-macros", "wmlflip", "wmlparser" and "umc-dev/build/update_version" + tools to Python 3 * It's now possible to chat with oneself in SP campaigns. Chat is shown in replays. (Issue#1111) * Removed unused "scoutDefault", "journeylifter", "wescamp_import" and "wmlvalidator" Python tools * Fixed wmlscope not correctly performing expansion of square braces in filenames in some conditions diff --git a/utils/umc_dev/build/update_version b/utils/umc_dev/build/update_version old mode 100644 new mode 100755 index ff3fa86dd75..22669589b08 --- a/utils/umc_dev/build/update_version +++ b/utils/umc_dev/build/update_version @@ -1,25 +1,27 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 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"] +usage = """usage: update_version current_version new_version +e.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 + print(usage) else: - print "Replacing version ", sys.argv[1], " with ", sys.argv[2], "..." + 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, "wb") - for s in input.xreadlines(): - output.write(s.replace(stext, rtext)) - input.close() - output.close() + print("Processing: ", sourcePath) + with open(sourcePath) as infile, open(targetPath, "w") as outfile: + for line in infile: + outfile.write(line.replace(stext, rtext)) shutil.move (targetPath, sourcePath)