From 6917ff21519781f856096d48872be001e6086811 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 19 Jan 2021 09:57:11 +0100 Subject: [PATCH] Fix code generator and release manager for Python 2.x and 3.x --- dev/codegen.py | 9 +++++++-- dev/release.py | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dev/codegen.py b/dev/codegen.py index 41627fd..5b27b68 100755 --- a/dev/codegen.py +++ b/dev/codegen.py @@ -2,7 +2,7 @@ # ========================================================================== # ctools code generator # -# Copyright (C) 2018 Juergen Knoedlseder +# Copyright (C) 2018-2021 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,9 +23,14 @@ import os import sys import fileinput from datetime import date -from builtins import input import gammalib +# Fix Python 2.x. +try: + input = raw_input +except NameError: + pass + # ================= # # Confirm something # diff --git a/dev/release.py b/dev/release.py index dd19e19..555ed59 100755 --- a/dev/release.py +++ b/dev/release.py @@ -2,7 +2,7 @@ # ========================================================================== # ctools release manager # -# Copyright (C) 2016-2019 Juergen Knoedlseder +# Copyright (C) 2016-2021 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,6 +22,12 @@ import os import sys import commands +# Fix Python 2.x. +try: + input = raw_input +except NameError: + pass + # ================= # # Confirm something # @@ -43,7 +49,7 @@ def confirm(text): # Confirmation loop waiting = True while waiting: - confirmation = str(raw_input(text+' (y/n): ')) + confirmation = str(input(text+' (y/n): ')) if confirmation == 'q': sys.exit() elif confirmation == 'y': @@ -78,7 +84,7 @@ def commit(message): # Optionally enter a commit message if len(message) == 0: - message = str(raw_input("Please enter a commit message: ")) + message = str(input("Please enter a commit message: ")) # Stage all files os.system('git add -u') @@ -513,7 +519,7 @@ def main_menu(): # Wait for the input waiting = True while waiting: - choice = str(raw_input('Enter your choice: ')) + choice = str(input('Enter your choice: ')) if choice == '1' or choice == '2' or choice == '3' or choice == '4' or \ choice == '5' or choice == '6' or choice == 'q': waiting = False @@ -617,8 +623,8 @@ def package_version_menu(): # Get package version from input waiting = True while waiting: - version = str(raw_input("Current ctools version is '%s'. Please " - "enter new ctools version: " % current)) + version = str(input("Current ctools version is '%s'. Please " + "enter new ctools version: " % current)) if version == "q": sys.exit() if check_version(version) == False: -- libgit2 0.21.4