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 | 2 | # ========================================================================== |
| 3 | 3 | # ctools code generator |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2018 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2018-2021 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -23,9 +23,14 @@ import os |
| 23 | 23 | import sys |
| 24 | 24 | import fileinput |
| 25 | 25 | from datetime import date |
| 26 | -from builtins import input | |
| 27 | 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 | 36 | # Confirm something # | ... | ... |
dev/release.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # ctools release manager |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016-2019 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2021 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -22,6 +22,12 @@ import os |
| 22 | 22 | import sys |
| 23 | 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 | 33 | # Confirm something # |
| ... | ... | @@ -43,7 +49,7 @@ def confirm(text): |
| 43 | 49 | # Confirmation loop |
| 44 | 50 | waiting = True |
| 45 | 51 | while waiting: |
| 46 | - confirmation = str(raw_input(text+' (y/n): ')) | |
| 52 | + confirmation = str(input(text+' (y/n): ')) | |
| 47 | 53 | if confirmation == 'q': |
| 48 | 54 | sys.exit() |
| 49 | 55 | elif confirmation == 'y': |
| ... | ... | @@ -78,7 +84,7 @@ def commit(message): |
| 78 | 84 | |
| 79 | 85 | # Optionally enter a commit message |
| 80 | 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 | 89 | # Stage all files |
| 84 | 90 | os.system('git add -u') |
| ... | ... | @@ -513,7 +519,7 @@ def main_menu(): |
| 513 | 519 | # Wait for the input |
| 514 | 520 | waiting = True |
| 515 | 521 | while waiting: |
| 516 | - choice = str(raw_input('Enter your choice: ')) | |
| 522 | + choice = str(input('Enter your choice: ')) | |
| 517 | 523 | if choice == '1' or choice == '2' or choice == '3' or choice == '4' or \ |
| 518 | 524 | choice == '5' or choice == '6' or choice == 'q': |
| 519 | 525 | waiting = False |
| ... | ... | @@ -617,8 +623,8 @@ def package_version_menu(): |
| 617 | 623 | # Get package version from input |
| 618 | 624 | waiting = True |
| 619 | 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 | 628 | if version == "q": |
| 623 | 629 | sys.exit() |
| 624 | 630 | if check_version(version) == False: | ... | ... |