Skip to content
Browse files

ENH: use print function in ModuleWizard for compatibility

As reported by Alexandre Abbas, the use of the print statement
means that the ModuleWizard is incompatible with python3.
See, for example [1].  Since we want to let people develop
scripted modules against a binary build of slicer, we should
try to make the module wizard as general purpose as possible
so people can use any python they have installed.

[1] http://www.python.org/dev/peps/pep-3105/

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21647 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
1 parent edc50bd commit b672c509adb7abcd40e5226f9120d4d045c44816 @pieper pieper committed Jan 29, 2013
Showing with 20 additions and 20 deletions.
  1. +20 −20 Utilities/Scripts/ModuleWizard.py
View
40 Utilities/Scripts/ModuleWizard.py
@@ -28,7 +28,7 @@ def findSource(dir):
def copyAndReplace(inFile, template, target, key, moduleName):
newFile = os.path.join( target, inFile.replace(key, moduleName) )
- print "creating %s" % newFile
+ print ("creating %s" % newFile)
path = os.path.dirname(newFile)
if not os.path.exists(path):
os.makedirs(path)
@@ -44,19 +44,19 @@ def copyAndReplace(inFile, template, target, key, moduleName):
def usage():
- print ""
- print "Usage:"
- print "ModuleWizard [--template <dir>] [--templateKey <key>] [--target <dir>] <moduleName>"
- print " --template default ./Extensions/Testing/LoadableExtensionTemplate"
- print " --templateKey default is dirname of template"
- print " --target default ./Modules/Loadable/<moduleName>"
- print "Examples (from Slicer source directory):"
- print " ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/LoadableExtensionTemplate --target ../MyExtension MyExtension"
- print " ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/ScriptedLoadableExtensionTemplate --target ../MyScript MyScript"
- print " ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/EditorExtensionTemplate --target ../MyEditorEffect MyEditorEffect"
- print " ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/CLIExtensionTemplate --target ../MyCLI MyCLI"
- print " ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/SuperBuildLoadableExtensionTemplate --target ../MySuperBuild MySuperBuild"
- print ""
+ print ("")
+ print ("Usage:")
+ print ("ModuleWizard [--template <dir>] [--templateKey <key>] [--target <dir>] <moduleName>")
+ print (" --template default ./Extensions/Testing/LoadableExtensionTemplate")
+ print (" --templateKey default is dirname of template")
+ print (" --target default ./Modules/Loadable/<moduleName>")
+ print ("Examples (from Slicer source directory):")
+ print (" ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/LoadableExtensionTemplate --target ../MyExtension MyExtension")
+ print (" ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/ScriptedLoadableExtensionTemplate --target ../MyScript MyScript")
+ print (" ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/EditorExtensionTemplate --target ../MyEditorEffect MyEditorEffect")
+ print (" ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/CLIExtensionTemplate --target ../MyCLI MyCLI")
+ print (" ./Utilities/Scripts/ModuleWizard.py --template ./Extensions/Testing/SuperBuildLoadableExtensionTemplate --target ../MySuperBuild MySuperBuild")
+ print ("")
def main(argv):
@@ -82,7 +82,7 @@ def main(argv):
moduleName = arg
if moduleName == "":
- print "Please specify module name"
+ print ("Please specify module name")
usage()
exit()
@@ -98,23 +98,23 @@ def main(argv):
target = "Modules/Loadable/" + moduleName
if os.path.exists(target):
- print target, "exists - delete it first"
+ print (target, "exists - delete it first")
exit()
if not os.path.exists(template):
- print template, "does not exist - run from Slicer source dir or specify with --template"
+ print (template, "does not exist - run from Slicer source dir or specify with --template")
usage()
exit()
- print "\nWill copy \n\t%s \nto \n\t%s \nreplacing \"%s\" with \"%s\"\n" % (template, target, templateKey, moduleName)
+ print ("\nWill copy \n\t%s \nto \n\t%s \nreplacing \"%s\" with \"%s\"\n" % (template, target, templateKey, moduleName))
sources = findSource( template )
- print sources
+ print (sources)
for file in sources:
copyAndReplace(file, template, target, templateKey, moduleName)
- print '\nModule %s created!' % moduleName
+ print ('\nModule %s created!' % moduleName)
if __name__ == "__main__":
main(sys.argv[1:])

0 comments on commit b672c50

Please sign in to comment.
Something went wrong with that request. Please try again.