summaryrefslogtreecommitdiffstats
path: root/clang/utils/analyzer/SATestAdd.py
diff options
context:
space:
mode:
authorSerge Guelton <sguelton@quarkslab.com>2018-12-18 08:36:33 +0000
committerSerge Guelton <sguelton@quarkslab.com>2018-12-18 08:36:33 +0000
commitc0ebe773cd0fb301474430205c69440f9915d5b0 (patch)
tree15c98a08b79b0dddbfeea4f95372771ba44d4dd1 /clang/utils/analyzer/SATestAdd.py
parent85833393d0e588f6d7613567db9c212236e3f0eb (diff)
downloadbcm5719-llvm-c0ebe773cd0fb301474430205c69440f9915d5b0.tar.gz
bcm5719-llvm-c0ebe773cd0fb301474430205c69440f9915d5b0.zip
Portable Python script across Python version
Using from __future__ import print_function it is possible to have a compatible behavior of `print(...)` across Python version. Differential Revision: https://reviews.llvm.org/D55213 llvm-svn: 349454
Diffstat (limited to 'clang/utils/analyzer/SATestAdd.py')
-rwxr-xr-xclang/utils/analyzer/SATestAdd.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/utils/analyzer/SATestAdd.py b/clang/utils/analyzer/SATestAdd.py
index 041b24409fe..377897e143d 100755
--- a/clang/utils/analyzer/SATestAdd.py
+++ b/clang/utils/analyzer/SATestAdd.py
@@ -42,6 +42,7 @@ the Repository Directory.
diff -ur CachedSource PatchedSource \
> changes_for_analyzer.patch
"""
+from __future__ import print_function
import SATestBuild
import os
@@ -66,7 +67,7 @@ def addNewProject(ID, BuildMode):
CurDir = os.path.abspath(os.curdir)
Dir = SATestBuild.getProjectDir(ID)
if not os.path.exists(Dir):
- print "Error: Project directory is missing: %s" % Dir
+ print("Error: Project directory is missing: %s" % Dir)
sys.exit(-1)
# Build the project.
@@ -78,30 +79,30 @@ def addNewProject(ID, BuildMode):
if os.path.exists(ProjectMapPath):
FileMode = "r+b"
else:
- print "Warning: Creating the Project Map file!!"
+ print("Warning: Creating the Project Map file!!")
FileMode = "w+b"
with open(ProjectMapPath, FileMode) as PMapFile:
if (isExistingProject(PMapFile, ID)):
- print >> sys.stdout, 'Warning: Project with ID \'', ID, \
- '\' already exists.'
- print >> sys.stdout, "Reference output has been regenerated."
+ print('Warning: Project with ID \'', ID, \
+ '\' already exists.', file=sys.stdout)
+ print("Reference output has been regenerated.", file=sys.stdout)
else:
PMapWriter = csv.writer(PMapFile)
PMapWriter.writerow((ID, int(BuildMode)))
- print "The project map is updated: ", ProjectMapPath
+ print("The project map is updated: ", ProjectMapPath)
# TODO: Add an option not to build.
# TODO: Set the path to the Repository directory.
if __name__ == '__main__':
if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):
- print >> sys.stderr, 'Add a new project for testing to the analyzer'\
+ print('Add a new project for testing to the analyzer'\
'\nUsage: ', sys.argv[0],\
'project_ID <mode>\n' \
'mode: 0 for single file project, ' \
'1 for scan_build, ' \
- '2 for single file c++11 project'
+ '2 for single file c++11 project', file=sys.stderr)
sys.exit(-1)
BuildMode = 1
OpenPOWER on IntegriCloud