Commit 6917ff21519781f856096d48872be001e6086811
1 parent
4751b829
Fix code generator and release manager for Python 2.x and 3.x
Showing
2 changed files
with
19 additions
and
8 deletions
dev/codegen.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # ctools code generator | 3 | # ctools code generator |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2018 Juergen Knoedlseder | 5 | +# Copyright (C) 2018-2021 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -23,9 +23,14 @@ import os | @@ -23,9 +23,14 @@ import os | ||
| 23 | import sys | 23 | import sys |
| 24 | import fileinput | 24 | import fileinput |
| 25 | from datetime import date | 25 | from datetime import date |
| 26 | -from builtins import input | ||
| 27 | import gammalib | 26 | import gammalib |
| 28 | 27 | ||
| 28 | +# Fix Python 2.x. | ||
| 29 | +try: | ||
| 30 | + input = raw_input | ||
| 31 | +except NameError: | ||
| 32 | + pass | ||
| 33 | + | ||
| 29 | 34 | ||
| 30 | # ================= # | 35 | # ================= # |
| 31 | # Confirm something # | 36 | # Confirm something # |
dev/release.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # ctools release manager | 3 | # ctools release manager |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2016-2019 Juergen Knoedlseder | 5 | +# Copyright (C) 2016-2021 Juergen Knoedlseder |
| 6 | # | 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -22,6 +22,12 @@ import os | @@ -22,6 +22,12 @@ import os | ||
| 22 | import sys | 22 | import sys |
| 23 | import commands | 23 | import commands |
| 24 | 24 | ||
| 25 | +# Fix Python 2.x. | ||
| 26 | +try: | ||
| 27 | + input = raw_input | ||
| 28 | +except NameError: | ||
| 29 | + pass | ||
| 30 | + | ||
| 25 | 31 | ||
| 26 | # ================= # | 32 | # ================= # |
| 27 | # Confirm something # | 33 | # Confirm something # |
| @@ -43,7 +49,7 @@ def confirm(text): | @@ -43,7 +49,7 @@ def confirm(text): | ||
| 43 | # Confirmation loop | 49 | # Confirmation loop |
| 44 | waiting = True | 50 | waiting = True |
| 45 | while waiting: | 51 | while waiting: |
| 46 | - confirmation = str(raw_input(text+' (y/n): ')) | 52 | + confirmation = str(input(text+' (y/n): ')) |
| 47 | if confirmation == 'q': | 53 | if confirmation == 'q': |
| 48 | sys.exit() | 54 | sys.exit() |
| 49 | elif confirmation == 'y': | 55 | elif confirmation == 'y': |
| @@ -78,7 +84,7 @@ def commit(message): | @@ -78,7 +84,7 @@ def commit(message): | ||
| 78 | 84 | ||
| 79 | # Optionally enter a commit message | 85 | # Optionally enter a commit message |
| 80 | if len(message) == 0: | 86 | if len(message) == 0: |
| 81 | - message = str(raw_input("Please enter a commit message: ")) | 87 | + message = str(input("Please enter a commit message: ")) |
| 82 | 88 | ||
| 83 | # Stage all files | 89 | # Stage all files |
| 84 | os.system('git add -u') | 90 | os.system('git add -u') |
| @@ -513,7 +519,7 @@ def main_menu(): | @@ -513,7 +519,7 @@ def main_menu(): | ||
| 513 | # Wait for the input | 519 | # Wait for the input |
| 514 | waiting = True | 520 | waiting = True |
| 515 | while waiting: | 521 | while waiting: |
| 516 | - choice = str(raw_input('Enter your choice: ')) | 522 | + choice = str(input('Enter your choice: ')) |
| 517 | if choice == '1' or choice == '2' or choice == '3' or choice == '4' or \ | 523 | if choice == '1' or choice == '2' or choice == '3' or choice == '4' or \ |
| 518 | choice == '5' or choice == '6' or choice == 'q': | 524 | choice == '5' or choice == '6' or choice == 'q': |
| 519 | waiting = False | 525 | waiting = False |
| @@ -617,8 +623,8 @@ def package_version_menu(): | @@ -617,8 +623,8 @@ def package_version_menu(): | ||
| 617 | # Get package version from input | 623 | # Get package version from input |
| 618 | waiting = True | 624 | waiting = True |
| 619 | while waiting: | 625 | while waiting: |
| 620 | - version = str(raw_input("Current ctools version is '%s'. Please " | ||
| 621 | - "enter new ctools version: " % current)) | 626 | + version = str(input("Current ctools version is '%s'. Please " |
| 627 | + "enter new ctools version: " % current)) | ||
| 622 | if version == "q": | 628 | if version == "q": |
| 623 | sys.exit() | 629 | sys.exit() |
| 624 | if check_version(version) == False: | 630 | if check_version(version) == False: |