From: vsr Date: Mon, 9 Apr 2012 11:50:46 +0000 (+0000) Subject: Improve dialog generation script (add verbose parameter, to use silent mode in Makefi... X-Git-Tag: V6_5_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d4ff898de5d165eb771fb34c5b8909452c1ee28;p=modules%2Fgui.git Improve dialog generation script (add verbose parameter, to use silent mode in Makefile.am) --- diff --git a/tools/dlgfactory/Makefile.am b/tools/dlgfactory/Makefile.am index bff7070a1..ccd46fa32 100644 --- a/tools/dlgfactory/Makefile.am +++ b/tools/dlgfactory/Makefile.am @@ -66,10 +66,10 @@ mostlyclean-local: rm -f @builddir@/*_moc.cxx @builddir@/ui_*.hxx QDialogTest.hxx QDialogTest.cxx QDialogTest.ui: $(QDIALOG_TEMPLATES) dlgfactory.py - $(srcdir)/dlgfactory.py -n QDialogTest -t qdialog + $(srcdir)/dlgfactory.py -s -n QDialogTest -t qdialog GDialogTest.hxx GDialogTest.cxx GDialogTest.ui : $(GDIALOG_TEMPLATES) dlgfactory.py - $(srcdir)/dlgfactory.py -n GDialogTest -t gdialog + $(srcdir)/dlgfactory.py -s -n GDialogTest -t gdialog QT_CXXFLAGS=@QT_INCLUDES@ @QT_MT_INCLUDES@ QT_LIBS=@QT_LIBS@ diff --git a/tools/dlgfactory/dlgfactory.py b/tools/dlgfactory/dlgfactory.py index 8774a815a..6b38facc9 100755 --- a/tools/dlgfactory/dlgfactory.py +++ b/tools/dlgfactory/dlgfactory.py @@ -1,23 +1,19 @@ #!/usr/bin/env python import sys, os -from optparse import OptionParser -import shutil, fileinput - -descr_str = """ - This script generates a set of files to initiate a dialog qt window - (i.e. MyDialog.ui, MyDialog.hxx and MyDialog.cxx files). - - The dialog window can be a self-consistent class (i.e. depends only - on Qt classes) or a classe that inherits from the class - GenericDialog whose implementation is provided in this package and - whose design is defined by the GenericDialog.ui file (editable using - the qt designer). - - The -t option let you choose between the two possibilities (specify - "-t qdialog" for the first case, "-t gdialog" otherwise). -""" -msg_str = """ + +__descr_str = "" +__descr_str += "This script generates a set of files to initiate a dialog Qt window " +__descr_str += "(i.e. MyDialog.ui, MyDialog.hxx and MyDialog.cxx files). " +__descr_str += "The dialog window can be a self-consistent class (i.e. depends only " +__descr_str += "on Qt classes) or a class that inherits class GenericDialog " +__descr_str += "which implementation is provided in this package and " +__descr_str += "which design is defined by the GenericDialog.ui file (editable using " +__descr_str += "the Qt designer). " +__descr_str += "The -t option let you choose between the two possibilities (specify " +__descr_str += "\"-t qdialog\" for the first case, \"-t gdialog\" otherwise)." + +__msg_str = """ # # --------------------------------------------------------- # Generation rules to create moc files from QObject headers @@ -65,36 +61,46 @@ salomeinclude_HEADERS += __CLASSNAME__.hxx $(QT_LIBS) """ -tool_path = os.path.dirname( os.path.abspath(__file__) ) - -parser = OptionParser(description=descr_str) -parser.add_option("-n", action="store", default="TestDialog", - help="specify the name of the class (default is TestDialog)", metavar="className") -parser.add_option("-t", action="store", default="qdialog", - choices=["qdialog", "gdialog"], - help="specify the type of the class (default is qdialog)", metavar="classType") - -(options, args) = parser.parse_args() -className = options.n -classType = options.t - -sep = os.path.sep -for ext in [".cxx", ".hxx", ".ui"]: - file_dest = className + ext - if classType == "qdialog": - file_src = tool_path + sep + "__QDIALOG__" + ext - else: - file_src = tool_path + sep + "__GDIALOG__" + ext - shutil.copyfile(file_src, file_dest) - finput = fileinput.FileInput(file_dest,inplace=1) - for line in finput: - line = line[:-1] - line = line.replace("__CLASSNAME__",className) - print line - -print "Note that the following directives should be present in your Makefile.am (or something like that): \n" -print msg_str.replace("__CLASSNAME__",className) - - - - \ No newline at end of file +if __name__ == "__main__": + from optparse import OptionParser + import shutil, fileinput + + tool_path = os.path.dirname( os.path.abspath( sys.argv[0] ) ) + + parser = OptionParser( description = __descr_str ) + parser.add_option( "-n", action="store", default="TestDialog", dest="className", metavar="className", + help="specify the name of the class (default is TestDialog)" ) + parser.add_option( "-t", action="store", default="qdialog", dest="classType", + choices=["qdialog", "gdialog"], metavar="classType", + help="specify the type of the class (default is qdialog)" ) + parser.add_option( "-v", "--verbose", action="store_true", default=True, dest="verbose", + help="verbose mode" ) + parser.add_option( "-s", "--silent", action="store_false", dest="verbose", + help="silent mode" ) + + (options, args) = parser.parse_args() + className = options.className + classType = options.classType + + for ext in [".cxx", ".hxx", ".ui"]: + file_dest = className + ext + if classType == "qdialog": + file_src = os.path.join( tool_path, "__QDIALOG__" + ext ) + pass + else: + file_src = os.path.join( tool_path, "__GDIALOG__" + ext ) + pass + shutil.copyfile( file_src, file_dest ) + finput = fileinput.FileInput( file_dest, inplace=1 ) + for line in finput: + line = line[:-1] + line = line.replace( "__CLASSNAME__", className ) + print line + pass + + if options.verbose: + print "Note that the following directives should be present in your Makefile.am (or something like that): \n" + print __msg_str.replace( "__CLASSNAME__", className ) + pass + pass +