Python 3 compatibility for the helper scripts
print() is a function in python 3. Works with pyhton 2.x, too.
This commit is contained in:
parent
db123c2c9b
commit
a2885a1759
|
@ -135,8 +135,8 @@ def writeHtmlFile(nodes, functionName, filename, errorsOnly):
|
|||
|
||||
|
||||
if len(sys.argv) <= 1 or '--help' in sys.argv:
|
||||
print 'Extract test cases from test file'
|
||||
print 'Syntax: extracttests.py [--html=folder] [--xml] [--code=folder] path/testfile.cpp'
|
||||
print ('Extract test cases from test file')
|
||||
print ('Syntax: extracttests.py [--html=folder] [--xml] [--code=folder] path/testfile.cpp')
|
||||
sys.exit(0)
|
||||
|
||||
# parse command line
|
||||
|
@ -154,7 +154,7 @@ for arg in sys.argv[1:]:
|
|||
elif arg.endswith('.cpp'):
|
||||
filename = arg
|
||||
else:
|
||||
print 'Invalid option: ' + arg
|
||||
print ('Invalid option: ' + arg)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
@ -166,8 +166,8 @@ if filename != None:
|
|||
|
||||
# generate output
|
||||
if xml:
|
||||
print '<?xml version="1.0"?>'
|
||||
print '<tree>'
|
||||
print ('<?xml version="1.0"?>')
|
||||
print ('<tree>')
|
||||
count = 0
|
||||
for node in e.nodes:
|
||||
s = ' <node'
|
||||
|
@ -175,8 +175,8 @@ if filename != None:
|
|||
s += ' code="' + strtoxml(node['code']) + '"'
|
||||
s += ' expected="' + strtoxml(node['expected']) + '"'
|
||||
s += '/>'
|
||||
print s
|
||||
print '</tree>'
|
||||
print (s)
|
||||
print ('</tree>')
|
||||
elif htmldir != None:
|
||||
if not htmldir.endswith('/'):
|
||||
htmldir += '/'
|
||||
|
@ -277,4 +277,4 @@ if filename != None:
|
|||
errors.close()
|
||||
else:
|
||||
for node in e.nodes:
|
||||
print node['functionName']
|
||||
print (node['functionName'])
|
||||
|
|
|
@ -31,7 +31,7 @@ def compileCmd(tok):
|
|||
elif tok == '%varid%':
|
||||
return '(tok->isName() && tok->varId()==varid)'
|
||||
elif (len(tok)>2) and (tok[0]=="%"):
|
||||
print "unhandled:" + tok
|
||||
print ("unhandled:" + tok)
|
||||
return '(tok->str()=="'+tok+'")'
|
||||
|
||||
def compilePattern(pattern, nr, varid):
|
||||
|
@ -189,9 +189,9 @@ def convertFile(srcname, destname):
|
|||
# selftests..
|
||||
def assertEquals(actual,expected):
|
||||
if actual!=expected:
|
||||
print 'Assertion failed:'
|
||||
print actual
|
||||
print expected
|
||||
print ('Assertion failed:')
|
||||
print (actual)
|
||||
print (expected)
|
||||
assert actual == expected
|
||||
assertEquals(parseMatch(' Token::Match(tok, ";") ',2), ['Token::Match(tok, ";")','tok',' ";"'])
|
||||
assertEquals(parseMatch(' Token::Match(tok,', 2), None) # multiline Token::Match is not supported yet
|
||||
|
@ -199,6 +199,6 @@ assertEquals(parseMatch(' Token::Match(Token::findsimplematch(tok,")"), ";")',
|
|||
|
||||
# convert all lib/*.cpp files
|
||||
for f in glob.glob('lib/*.cpp'):
|
||||
print f + ' => build/' + f[4:]
|
||||
print (f + ' => build/' + f[4:])
|
||||
convertFile(f, 'build/'+f[4:])
|
||||
|
||||
|
|
Loading…
Reference in New Issue