From 892eff3be6671464189bd28a0e9de6d18e54701b Mon Sep 17 00:00:00 2001 From: smihica Date: Thu, 29 May 2014 10:46:57 +0900 Subject: To make tools/json2hash work in both python2.7 and 3.X --- tools/json2hash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tools/json2hash') diff --git a/tools/json2hash b/tools/json2hash index afa50b2..ce7ee58 100755 --- a/tools/json2hash +++ b/tools/json2hash @@ -5,7 +5,14 @@ import sys import os import re import argparse -from cStringIO import StringIO + +python2 = sys.version_info[0] == 2 +python3 = sys.version_info[0] == 3 + +if python2: + from cStringIO import StringIO +if python3: + from io import StringIO class ApplicationException(Exception): pass @@ -89,4 +96,7 @@ if __name__ == '__main__': try: main() except ApplicationException as e: - print >>sys.stderr, e.message + if python2: + print >> sys.stderr, e.message + elif python3: + print(e.meesage, file=sys.stderr) -- cgit v1.2.3