py/makeqstrdefs.py: Make script run correctly with Python 2.6.

pull/3130/merge
Damien George 2017-06-09 13:42:13 +10:00
rodzic a8a5d1e8c8
commit b24ccfc639
1 zmienionych plików z 13 dodań i 11 usunięć

Wyświetl plik

@ -5,8 +5,10 @@ qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'.
This script works with Python 2.6, 2.7, 3.3 and 3.4. This script works with Python 2.6, 2.7, 3.3 and 3.4.
""" """
from __future__ import print_function
import re import re
import argparse import sys
import os import os
# Blacklist of qstrings that are specially handled in further # Blacklist of qstrings that are specially handled in further
@ -84,18 +86,18 @@ def cat_together():
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Generates qstr definitions from a specified source') if len(sys.argv) != 5:
print('usage: %s command input_filename output_dir output_file' % sys.argv[0])
sys.exit(2)
parser.add_argument('command', class Args:
help='Command (split/cat)') pass
parser.add_argument('input_filename', args = Args()
help='Name of the input file (when not specified, the script reads standard input)') args.command = sys.argv[1]
parser.add_argument('output_dir', args.input_filename = sys.argv[2]
help='Output directory to store individual qstr files') args.output_dir = sys.argv[3]
parser.add_argument('output_file', args.output_file = sys.argv[4]
help='Name of the output file with collected qstrs')
args = parser.parse_args()
try: try:
os.makedirs(args.output_dir) os.makedirs(args.output_dir)
except OSError: except OSError: