Make hip_prof_gen.py compatible with both python 2 and 3
Convert python 2 constructs to python 3 compatible ones. In python 3, print is a function, so use write methods (which are always functions) instead. In python3 keys() returns an iterator, rather than a list. This means you can't change the data structure that is being iterated over. Converting this iterator into a list mimics the python 2 behavior.
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
bc528b1e8b
commit
cc374b2bd3
+4
-4
@@ -13,7 +13,7 @@ line_num = -1
|
|||||||
|
|
||||||
# Verbose message
|
# Verbose message
|
||||||
def message(msg):
|
def message(msg):
|
||||||
if verbose: print >>sys.stdout, msg
|
if verbose: sys.stdout.write(msg + '\n')
|
||||||
|
|
||||||
# Fatal error termination
|
# Fatal error termination
|
||||||
def error(msg):
|
def error(msg):
|
||||||
@@ -24,8 +24,8 @@ def error(msg):
|
|||||||
else:
|
else:
|
||||||
msg = " Warning: " + msg
|
msg = " Warning: " + msg
|
||||||
|
|
||||||
print >>sys.stdout, msg
|
sys.stdout.write(msg + '\n')
|
||||||
print >>sys.stderr, sys.argv[0] + msg
|
sys.stderr.write(sys.argv[0] + msg +'\n')
|
||||||
|
|
||||||
def fatal(msg):
|
def fatal(msg):
|
||||||
error(msg)
|
error(msg)
|
||||||
@@ -451,7 +451,7 @@ parse_api(api_hfile, api_map)
|
|||||||
parse_src(api_map, src_dir, src_pat, opts_map)
|
parse_src(api_map, src_dir, src_pat, opts_map)
|
||||||
|
|
||||||
# Checking for non-conformant APIs
|
# Checking for non-conformant APIs
|
||||||
for name in opts_map.keys():
|
for name in list(opts_map.keys()):
|
||||||
m = re.match(r'\.(\S*)', name)
|
m = re.match(r'\.(\S*)', name)
|
||||||
if m:
|
if m:
|
||||||
message("Init missing: " + m.group(1))
|
message("Init missing: " + m.group(1))
|
||||||
|
|||||||
Reference in New Issue
Block a user