55# This one has the scripting bridge enabled.
66
77import sys
8- if sys .version_info < (3 , 6 ):
9- print "set-xcode-analyzer requires Python 3.6 or later"
10- sys .exit (1 )
11-
128import os
139import subprocess
1410import re
@@ -18,7 +14,7 @@ import stat
1814from AppKit import *
1915
2016def FindClangSpecs (path ):
21- print "(+) Searching for xcspec file in: " , path
17+ print ( "(+) Searching for xcspec file in: " , path )
2218 for root , dirs , files in os .walk (path ):
2319 for f in files :
2420 if f .endswith (".xcspec" ) and f .startswith ("Clang LLVM" ):
@@ -49,14 +45,14 @@ def ModifySpec(path, isBuiltinAnalyzer, pathToChecker):
4945 foundAnalyzer = False
5046 t .write (line )
5147 t .close ()
52- print "(+) processing:" , path
48+ print ( "(+) processing:" , path )
5349 try :
5450 shutil .copy (t .name , path )
5551 os .chmod (path , stat .S_IRUSR | stat .S_IWUSR | stat .S_IRGRP | stat .S_IROTH )
56- except IOError , why :
57- print " (-) Cannot update file:" , why , "\n "
58- except OSError , why :
59- print " (-) Cannot update file:" , why , "\n "
52+ except IOError as why :
53+ print ( " (-) Cannot update file:" , why , "\n " )
54+ except OSError as why :
55+ print ( " (-) Cannot update file:" , why , "\n " )
6056 os .unlink (t .name )
6157
6258def main ():
@@ -75,20 +71,20 @@ def main():
7571 # determine if Xcode is running
7672 for x in NSWorkspace .sharedWorkspace ().runningApplications ():
7773 if x .localizedName ().find ("Xcode" ) >= 0 :
78- print "(-) You must quit Xcode first before modifying its configuration files."
74+ print ( "(-) You must quit Xcode first before modifying its configuration files." )
7975 sys .exit (1 )
8076
8177 isBuiltinAnalyzer = False
8278 if options .path :
8379 # Expand tildes.
8480 path = os .path .expanduser (options .path )
8581 if not path .endswith ("clang" ):
86- print "(+) Using Clang bundled with checker build:" , path
82+ print ( "(+) Using Clang bundled with checker build:" , path )
8783 path = os .path .join (path , "bin" , "clang" );
8884 else :
89- print "(+) Using Clang located at:" , path
85+ print ( "(+) Using Clang located at:" , path )
9086 else :
91- print "(+) Using the Clang bundled with Xcode"
87+ print ( "(+) Using the Clang bundled with Xcode" )
9288 path = options .default
9389 isBuiltinAnalyzer = True
9490
@@ -108,7 +104,7 @@ def main():
108104 ModifySpec (x , isBuiltinAnalyzer , path )
109105
110106 if not foundSpec :
111- print "(-) No compiler configuration file was found. Xcode's analyzer has not been updated."
107+ print ( "(-) No compiler configuration file was found. Xcode's analyzer has not been updated." )
112108
113109if __name__ == '__main__' :
114110 main ()
0 commit comments