Salome HOME
Merge Python 3 porting.
authorrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 14:32:06 +0000 (17:32 +0300)
committerrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 14:32:06 +0000 (17:32 +0300)
55 files changed:
adm_local/unix/config_files/check_pyqt.m4
bin/gui_setenv.py
bin/runLightSalome.csh
bin/runLightSalome.sh
src/GUI_PY/dockwidgets.py
src/GUI_PY/genericdialog.py
src/GUI_PY/helper.py
src/GUI_PY/mytestdialog.py
src/GUI_PY/selectvars.py
src/GUI_PY/test_dockwidgets.py
src/LightApp/LightApp_Application.cxx
src/PVServerService/PVServer_ServiceWrapper.cxx
src/PVServerService/ServiceLoader/CMakeLists.txt
src/Plot2d/Plot2d_AnalyticalParser.cxx
src/SALOME_PY/SalomePy.cxx
src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyInterp.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx
src/SALOME_SWIG/CMakeLists.txt
src/SALOME_SWIG/test_big_table.py
src/SALOME_SWIG/test_remove_ref.py
src/SALOME_SWIG/test_table.py
src/SUITApp/SUITApp_init_python.cxx
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Study.cxx
src/SalomeApp/Test/TestSalomeApp.py
src/SalomeApp/pluginsdemo/salome_plugins.py
src/SalomeApp/pluginsdemo/smesh_plugins.py
src/SalomeApp/pluginsdemo/tubebuilder.py
src/SalomeApp/pluginsdemo/tubedialog.py
src/SalomeApp/salome_pluginsmanager.py
src/Session/SALOME_Session_Server.cxx
tools/CurvePlot/src/python/controller/PlotController.py
tools/CurvePlot/src/python/controller/__init__.py
tools/CurvePlot/src/python/controller/utils.py.in
tools/CurvePlot/src/python/model/PlotManager.py
tools/CurvePlot/src/python/model/XYPlotSetModel.py
tools/CurvePlot/src/python/pyqtside/__init__.py
tools/CurvePlot/src/python/pyqtside/uic.py
tools/CurvePlot/src/python/test/PlotCurve_Standalone.py
tools/CurvePlot/src/python/test/PlotTestBase.py
tools/CurvePlot/src/python/test/TestDesktop.py
tools/CurvePlot/src/python/test/plot_test.py
tools/CurvePlot/src/python/ui/PlotSettings.py
tools/CurvePlot/src/python/views/CurveBrowserView.py
tools/CurvePlot/src/python/views/CurveTabsView.py
tools/CurvePlot/src/python/views/XYView.py
tools/PyConsole/src/PyConsole_Console.cxx
tools/PyConsole/src/PyConsole_Editor.cxx
tools/PyConsole/src/PyConsole_Interp.cxx
tools/PyConsole/src/PyConsole_Interp.h
tools/PyInterp/src/PyInterp_Interp.cxx
tools/PyInterp/src/PyInterp_Utils.h
tools/dlgfactory/dlgfactory.py

index 16878d41e499c3c65751f57aac45af4463c5b5da..cfeca417d24b90a2c43c23a296f175ac4bdf7128 100644 (file)
@@ -236,7 +236,7 @@ if test "x$pyqt_ok" == "xyes" ; then
                     #    SUPPORTED=${QT_VERSION}
                     #fi
                     #SUPPORTED="Qt_`echo ${SUPPORTED} | sed -e 's/\./_/g'`"
-                   PYQT_SIPFLAGS=`python -c "from PyQt4 import pyqtconfig; print pyqtconfig.Configuration().pyqt_sip_flags"`
+                   PYQT_SIPFLAGS=`python -c "from PyQt4 import pyqtconfig; print(pyqtconfig.Configuration().pyqt_sip_flags)"`
                     PYQT_SIPFLAGS="${PYQT_SIPFLAGS} -s .cc -c . ${PYQT_INCLUDES}"
                     break
                 fi
index 5a4a44be37df54a0df354c9a3e41ecb7996f9f22..d1f90c71489c9685cc09d2f11b73a61cf045b6e9 100644 (file)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 #  -*- coding: iso-8859-1 -*-
 # Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
index 5c13349fd95ae91fd4f5efdd3330722403865119..6ea222f7e90b370e2af0dd9ebd60ab1a5c3063f3 100755 (executable)
@@ -86,7 +86,7 @@ end
 # set additional environment
 ###
 
-set python_version=`python -c "import sys; print sys.version[:3]"`
+set python_version=`python -c "import sys; print(sys.version[:3])"`
 
 set MY_PATH=""
 set MY_LD_LIBRARY_PATH=""
index 57fecc31a3a6fa31a47240c914cd6df5808c0f2f..caf368e8f4ca18df9f3d3557537987d9a10cfd74 100755 (executable)
@@ -214,7 +214,7 @@ run_light_salome(){
     # set additional environment
     ###
 
-    local PVERSION=`python -c "import sys; print sys.version[:3]" 2>/dev/null`
+    local PVERSION=`python -c "import sys; print(sys.version[:3])" 2>/dev/null`
     
     local MY_PATH=""
     local MY_LD_LIBRARY_PATH=""
index 08a9bc77be36580be2fd70d84c42f43e8ca8f1c9..5d43064240581fdc0140889da4d1412f6146a025 100644 (file)
@@ -43,7 +43,7 @@ def findDockWidgetByTitle( title ):
     """
     sg = SalomePyQt.SalomePyQt()
     dwl = sg.getDesktop().findChildren( QDockWidget )
-    dw = filter(lambda a: a.windowTitle() == str( title ), dwl)
+    dw = [a for a in dwl if a.windowTitle() == str( title )]
     if dw: return dw[0]
     return None
 
index 2a310a4e7c8bfbab87460b15cbec2d7d28aa8685..78183833b4fe84125b37cf7e5a439324cf0b448f 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-__author__="gboulant"
-__date__ ="$31 mars 2010 17:09:53$"
-
 from qtsalome import QDialog, QMessageBox
+from salome.gui.genericdialog_ui import Ui_GenericDialog
 
-from genericdialog_ui import Ui_GenericDialog
 
 class GenericDialog(QDialog):
     """
@@ -120,9 +117,9 @@ def TEST_GenericDialog():
     dlg=GenericDialog()
     dlg.displayAndWait()
     if dlg.wasOk():
-        print "OK has been pressed"
+        print("OK has been pressed")
     else:
-        print "Cancel has been pressed"
+        print("Cancel has been pressed")
         
 if __name__ == "__main__":
     TEST_GenericDialog()
index d1f0ca992a75e7d48bbbae655b0d0432127b9ef9..890367e7c384372e8444d8fe51f2e7060ed77759 100644 (file)
@@ -86,7 +86,7 @@ def showSObjectSelected():
         test, attr = sobj.FindAttribute( "AttributeName" )
         if test:
             message = "My name is '%s'" % attr.Value()
-            print message
+            print(message)
     pass
 
 def deleteSObjectSelected(): 
@@ -123,7 +123,7 @@ def deleteSObjectSelected():
 def TEST_getSObjectSelected():
     mySObject, myEntry = getSObjectSelected()
     myName = mySObject.GetName()
-    print "The name of the selected object is %s"%myName
+    print("The name of the selected object is %s"%myName)
 
 def TEST_showSObjectSelected():
     showSObjectSelected()
index 2c975c11315c64e80e7e49fcc5764b38f143ceb5..baa2d7826d22b8181f79661a2403422c6b8d4482 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-__author__="gboulant"
-__date__ ="$31 mars 2010 17:09:53$"
 from qtsalome import *
-from mytestdialog_ui import Ui_MyTestDialog
-from genericdialog import GenericDialog
+from salome.gui.genericdialog import GenericDialog
+from salome.gui.mytestdialog_ui import Ui_MyTestDialog
+
 
 class MyTestDialog(GenericDialog):
     """
@@ -115,12 +114,12 @@ def TEST_MyTestDialog_modal():
     dlg.displayAndWait()
     if dlg.wasOk():
         name = dlg.getData()
-        print "The name has been modified to",name
+        print("The name has been modified to",name)
 
 
 class DialogListener:
     def onProcessEvent(self):
-        print "onProcessEvent(): OK has been pressed"
+        print("onProcessEvent(): OK has been pressed")
         import sys
         sys.exit(0)
         
index 07386820131ab39b0380bc4653cd72588a653097..b98138401ab1e979b729d5a686b177fbdc0ee2ee 100644 (file)
@@ -134,7 +134,7 @@ class MySelectVarsDialog(Ui_SelectVarsDialog, QDialog):
             filename = str(filename)
             exchange_variables = study_exchange_vars.loadExchangeVariablesFromXmlFile(filename)
             self.setExchangeVariables(exchange_variables)
-        except Exception, e:
+        except Exception as e:
             QMessageBox.critical(self, self.tr("Error"),
                                  self.tr("Cannot load file %s:\n%s" % (filename, e)))
 
@@ -148,6 +148,6 @@ class MySelectVarsDialog(Ui_SelectVarsDialog, QDialog):
             filename = str(filename)
             exchange_variables = self.getSelectedExchangeVariables()
             exchange_variables.saveToXmlFile(filename)
-        except Exception, e:
+        except Exception as e:
             QMessageBox.critical(self, self.tr("Error"),
                                  self.tr("Cannot save file %s:\n%s" % (filename, e)))
index d51d5234431b8037ae4702ac3fbe90225ba527ba..bf5805eaaf8723bb93474f1626a7b94de85324bb 100644 (file)
@@ -1,45 +1,45 @@
 from salome.gui.dockwidgets import *
 
-print "-- Search dock windows by title"
+print("-- Search dock windows by title")
 ob = findDockWidgetByTitle( "Object Browser" )
 if ob:
-    print "object browser:", ob
+    print("object browser:", ob)
 else:
-    print "object browser was not found"
+    print("object browser was not found")
 
 pc  = findDockWidgetByTitle( "Python Console" )
 if pc:
-    print "python console:", pc
+    print("python console:", pc)
 else:
-    print "python console was not found"
-print 
+    print("python console was not found")
+print() 
 
-print "-- Search dock windows by name"
+print("-- Search dock windows by name")
 ob = findDockWidgetByName( "objectBrowserDock" )
 if ob:
-    print "object browser:", ob
+    print("object browser:", ob)
 else:
-    print "object browser was not found"
+    print("object browser was not found")
 pc  = findDockWidgetByName( "pythonConsoleDock" )
 if pc:
-    print "python console:", pc
+    print("python console:", pc)
 else:
-    print "python console was not found"
-print 
+    print("python console was not found")
+print() 
 
-print "-- Search dock windows by id"
+print("-- Search dock windows by id")
 ob = findDockWidgetById( SalomePyQt.WT_ObjectBrowser )
 if ob:
-    print "object browser:", ob
+    print("object browser:", ob)
 else:
-    print "object browser was not found"
+    print("object browser was not found")
 pc  = findDockWidgetById( SalomePyQt.WT_PyConsole )
 if pc:
-    print "python console:", pc
+    print("python console:", pc)
 else:
-    print "python console was not found"
-print 
+    print("python console was not found")
+print() 
 
-print "-- Tabify dock windows"
+print("-- Tabify dock windows")
 tabifyDockWidgets( findDockWidgetById( SalomePyQt.WT_ObjectBrowser ),
                    findDockWidgetById( SalomePyQt.WT_PyConsole ) )
index 79e89bd6389b7fe30b5a2c23dc16e77a688d665b..afda2bbefd6cf356435f613426f1a58b4d502a26 100644 (file)
@@ -35,8 +35,8 @@
 #endif
 
 #ifndef DISABLE_PYCONSOLE
-  #include "LightApp_PyEditor.h"
   #include "PyConsole_Interp.h"
+  #include "LightApp_PyEditor.h"
   #include "PyConsole_Console.h"
 #endif
 
index 8c4004065e1fbd4911f7fb23887848cdf6234b9a..584a4da91e621735ea669caad755b7b595c934a8 100644 (file)
@@ -102,7 +102,7 @@ std::string PVServer_ServiceWrapper::FindOrStartPVServer(int port)
       PyErr_Print();
       throw SALOME_Exception("Unable to invoke PVSERVER service!");
     }
-  return std::string(PyString_AsString(obj));
+  return std::string(PyUnicode_AsUTF8(obj));
 }
 
 
index ee65c52375d812ab1e1fdc276b7291f46d459152..7e5c65ecedcc9bc7ffa8d017e45db031f810e472 100644 (file)
@@ -58,7 +58,7 @@ INSTALL(TARGETS PVServerServiceLoader EXPORT ${PROJECT_NAME}TargetGroup DESTINAT
 
 # --- SWIG part ---
 SET_SOURCE_FILES_PROPERTIES(${_SWIG} PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(${_SWIG} PROPERTIES SWIG_DEFINITIONS "-shadow")
+SET_SOURCE_FILES_PROPERTIES(${_SWIG} PROPERTIES SWIG_FLAGS "-py3")
 SWIG_ADD_MODULE(PVServer_ServiceLoader python ${_SWIG})
 IF(WIN32)
   SET_TARGET_PROPERTIES(_PVServer_ServiceLoader PROPERTIES DEBUG_OUTPUT_NAME _PVServer_ServiceLoader_d)
index 23b62a5b5b451738545ae1ab9a8265ae153e459c..09f963b80935a21f1d8deed5b5bfd953d39ec540 100755 (executable)
@@ -46,8 +46,7 @@ namespace {
   PyStdOut_write(PyStdOut *self, PyObject *args)
   {
     char *c;
-    int l;
-    if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
+    if (!PyArg_ParseTuple(args, "s",&c))
       return NULL;
 
     *(self->out)=*(self->out)+c;
@@ -71,8 +70,8 @@ namespace {
   static PyTypeObject PyStdOut_Type = {
     /* The ob_type field must be initialized in the module init function
      * to be portable to Windows without using C++. */
-    PyObject_HEAD_INIT(NULL)
-    0,                            /*ob_size*/
+    PyVarObject_HEAD_INIT(NULL, 0)
+    /* 0, */                           /*ob_size*/
     "PyOut",                      /*tp_name*/
     sizeof(PyStdOut),             /*tp_basicsize*/
     0,                            /*tp_itemsize*/
@@ -114,6 +113,14 @@ namespace {
     0,                            /*tp_new*/
     0,                            /*tp_free*/
     0,                            /*tp_is_gc*/
+    0,                            /*tp_bases*/
+    0,                            /*tp_mro*/
+    0,                            /*tp_cache*/
+    0,                            /*tp_subclasses*/
+    0,                            /*tp_weaklist*/
+    0,                            /*tp_del*/
+    0,                            /*tp_version_tag*/
+    0,                             /*tp_finalize*/  
   };
 
   PyObject * newPyStdOut( std::string& out )
@@ -179,7 +186,7 @@ int Plot2d_AnalyticalParser::calculate( const QString& theExpr,
 
   if(obj == NULL) {
     PyErr_Print();
-    PyGILState_Release(gstate);        
+    PyGILState_Release(gstate);
     return result;
     
   } else {
@@ -210,9 +217,9 @@ int Plot2d_AnalyticalParser::calculate( const QString& theExpr,
     PyGILState_Release(gstate);
     return result;
   }
-    
+
   PyObject* coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theMin, theMax, theNbStep );
-  
+
   if (coords == NULL){
     fflush(stderr);
     std::string err_description="";
@@ -253,22 +260,21 @@ int Plot2d_AnalyticalParser::calculate( const QString& theExpr,
 */
 void Plot2d_AnalyticalParser::initScript() {
   myScript.clear();
-  myScript += "from math import *                      \n";
-  myScript += "def Y(x):                               \n";
-  myScript += "    return ";
-  myScript += "%1\n";
+  myScript += "from math import *\n";
+  myScript += "def Y(x):\n";
+  myScript += "\treturn %1\n";
 
-  myScript += "def coordCalculator(xmin, xmax, nstep):     \n";
-  myScript += "   coords = []                              \n";
-  myScript += "   xstep  = (xmax - xmin) / nstep           \n";
-  myScript += "   n = 0                                    \n";
-  myScript += "   while n <= nstep :                       \n";
-  myScript += "      x = xmin + n*xstep                    \n";
-  myScript += "      try:                                  \n";
-  myScript += "                        y = Y(x)                           \n";
-  myScript += "                        coords.append([x,y])               \n";
-  myScript += "      except ValueError, ZeroDivisionError: \n";
-  myScript += "                        pass                               \n";
-  myScript += "      n = n+1                               \n";
-  myScript += "   return coords                            \n";
+  myScript += "def coordCalculator(xmin, xmax, nstep):\n";
+  myScript += "\tcoords = []\n";
+  myScript += "\txstep  = (xmax - xmin) / nstep\n";
+  myScript += "\tn = 0\n";
+  myScript += "\twhile n <= nstep :\n";
+  myScript += "\t\tx = xmin + n*xstep\n";
+  myScript += "\t\ttry:\n";
+  myScript += "\t\t\ty = Y(x)\n";
+  myScript += "\t\t\tcoords.append([x,y])\n";
+  myScript += "\t\texcept (ValueError, ZeroDivisionError):\n";
+  myScript += "\t\t\tpass\n";
+  myScript += "\t\tn = n+1\n";
+  myScript += "\treturn coords\n";
 }
index d099217b9fbd9616c526886a76074e9febff9210..ed7ce5028266f20f5c924da6d2ebe2943922fc26 100755 (executable)
 {                                                    \
   PyObject *w;                                       \
   int rc;                                            \
-  if ( ( w = PyInt_FromLong( i ) ) == NULL ) return; \
+  if ( ( w = PyLong_FromLong( i ) ) == NULL ) return NULL; \
   rc = PyDict_SetItemString( aModuleDict, #i, w );   \
   Py_DECREF( w );                                    \
-  if ( rc < 0 ) return;                              \
+  if ( rc < 0 ) return NULL;                              \
 }
 
 //! View operation type
@@ -494,7 +494,7 @@ extern "C" SALOMEPY_EXPORT PyObject* libSalomePy_resetView( PyObject* self, PyOb
   return Py_None;
 }
 
-static PyMethodDef Module_Methods[] = 
+static PyMethodDef libSalomePy_methods[] = 
 {
   { "getRenderer",               libSalomePy_getRenderer,               METH_VARARGS },
   { "getRenderWindow",           libSalomePy_getRenderWindow,           METH_VARARGS },
@@ -506,25 +506,51 @@ static PyMethodDef Module_Methods[] =
   { NULL, NULL }
 };
 
+struct module_state {
+    PyObject *error;
+};
+
+#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
+
+static int libSalomePy_traverse(PyObject *m, visitproc visit, void *arg) {
+    Py_VISIT(GETSTATE(m)->error);
+    return 0;
+}
+
+static int libSalomePy_clear(PyObject *m) {
+    Py_CLEAR(GETSTATE(m)->error);
+    return 0;
+}
+
+static struct PyModuleDef moduledef = {
+        PyModuleDef_HEAD_INIT,
+        "libSalomePy",
+        NULL,
+        sizeof(struct module_state),
+        libSalomePy_methods,
+        NULL,
+        libSalomePy_traverse,
+        libSalomePy_clear,
+        NULL
+};
+
 /*!
   \brief Python module initialization.
   \internal
 */
-extern "C" SALOMEPY_EXPORT void initlibSalomePy()
+extern "C" SALOMEPY_EXPORT PyMODINIT_FUNC PyInit_libSalomePy(void)
 {
-  static char* modulename = (char*)"libSalomePy";
-
   // init module
-  PyObject* aModule = Py_InitModule( modulename, Module_Methods );
+  PyObject *aModule = PyModule_Create(&moduledef);
   if( PyErr_Occurred() ) {
     PyErr_Print();
-    return;
+    return NULL;
   }
 
   // get module's dictionary
   PyObject *aModuleDict = PyModule_GetDict( aModule );
   if ( aModuleDict == NULL )
-    return;
+    return NULL;
 
   // export View type enumeration
   PUBLISH_ENUM( ViewFront );
@@ -533,4 +559,6 @@ extern "C" SALOMEPY_EXPORT void initlibSalomePy()
   PUBLISH_ENUM( ViewBottom );
   PUBLISH_ENUM( ViewRight );
   PUBLISH_ENUM( ViewLeft );
+
+  return aModule;
 }
index 069e070f374c4e99a9aac7256edd82d0f6468359..b1cb8ec9e02053c4d95fab9192dde14f472f1b47 100644 (file)
@@ -45,7 +45,7 @@
 // and to get C API from sip : sipBuildResult for example
 //
 
-#define INIT_FUNCTION initSalomePyQtGUILight
+#define INIT_FUNCTION PyInit_SalomePyQtGUILight
 #if defined(SIP_STATIC_MODULE)
 extern "C" void INIT_FUNCTION();
 #else
index 1cdcb36fced6a77e56b9cbd0d3ba2cb371291ee0..e405a40fa9fbc5e9326a85ae33c5d16788676d8f 100644 (file)
@@ -20,8 +20,8 @@
 // File   : SALOME_PYQT_ModuleLight.cxx
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 
-#include "SALOME_PYQT_DataModelLight.h"
 #include "SALOME_PYQT_ModuleLight.h"
+#include "SALOME_PYQT_DataModelLight.h"
 #include "SALOME_PYQT_PyModule.h"
 #include "SALOME_PYQT_Selector.h"
 
@@ -63,7 +63,7 @@
 // and to get C API from sip : sipBuildResult for example
 //
 
-#define INIT_FUNCTION initSalomePyQtGUILight
+#define INIT_FUNCTION PyInit_SalomePyQtGUILight
 #if defined(SIP_STATIC_MODULE)
 extern "C" void INIT_FUNCTION();
 #else
index 519e59457dbcb28ab1d424c41145908bd45de930..7bf7118531160b641a3f7b00ccdbb8a5e9f80817 100644 (file)
@@ -77,7 +77,7 @@ int SALOME_PYQT_PyInterp::run(const char *command)
     PyErr_Print();
     return -1;
   }
-  PyObject *r = PyEval_EvalCode((PyCodeObject *)code,_global_context,_local_context);
+  PyObject *r = PyEval_EvalCode((PyObject *)code,_global_context,_local_context);
 
   Py_DECREF(code);
   if(!r){
index f9d15e5879216ed0f2d567975183900cb1a9aa98..4264610e4a729b1ce54f23a7ed61ff541cccfa14 100644 (file)
@@ -1934,9 +1934,9 @@ void PyModuleHelper::internalInitialize( CAM_Application* app )
           // parse the return value
           // it should be a map: {integer:integer}
           int aKey, aValue;
-          if( key && PyInt_Check( key ) && value && PyInt_Check( value ) ) {
-            aKey   = PyInt_AsLong( key );
-            aValue = PyInt_AsLong( value );
+          if( key && PyLong_Check( key ) && value && PyLong_Check( value ) ) {
+            aKey   = PyLong_AsLong( key );
+            aValue = PyLong_AsLong( value );
             myWindowsMap[ aKey ] = aValue;
           }
         }
@@ -1954,16 +1954,16 @@ void PyModuleHelper::internalInitialize( CAM_Application* app )
     else {
       // parse the return value
       // result can be one string...
-      if ( PyString_Check( res2 ) ) {
-        myViewMgrList.append( PyString_AsString( res2 ) );
+      if ( PyUnicode_Check( res2 ) ) {
+        myViewMgrList.append( PyUnicode_AsUTF8( res2 ) );
       }
       // ... or list of strings
       else if ( PyList_Check( res2 ) ) {
         int size = PyList_Size( res2 );
         for ( int i = 0; i < size; i++ ) {
           PyObject* value = PyList_GetItem( res2, i );
-          if( value && PyString_Check( value ) ) {
-            myViewMgrList.append( PyString_AsString( value ) );
+          if( value && PyUnicode_Check( value ) ) {
+            myViewMgrList.append( PyUnicode_AsUTF8( value ) );
           }
         }
       }
@@ -2519,8 +2519,8 @@ void PyModuleHelper::internalSave( QStringList& files, const QString& url )
     else {
       // parse the return value
       // result can be one string...
-      if ( PyString_Check( res ) ) {
-        QString astr = PyString_AsString( res );
+      if ( PyUnicode_Check( res ) ) {
+        QString astr = PyUnicode_AsUTF8( res );
         files.append( astr );
       }
       //also result can be a list...
@@ -2528,8 +2528,8 @@ void PyModuleHelper::internalSave( QStringList& files, const QString& url )
         int size = PyList_Size( res );
         for ( int i = 0; i < size; i++ ) {
           PyObject* value = PyList_GetItem( res, i );
-          if ( value && PyString_Check( value ) ) {
-            files.append( PyString_AsString( value ) );
+          if ( value && PyUnicode_Check( value ) ) {
+            files.append( PyUnicode_AsUTF8( value ) );
           }
         }
       }
@@ -2607,8 +2607,8 @@ void PyModuleHelper::internalDumpPython( QStringList& files )
     else {
       // parse the return value
       // result can be one string...
-      if ( PyString_Check( res ) ) {
-        QString astr = PyString_AsString( res );
+      if ( PyUnicode_Check( res ) ) {
+        QString astr = PyUnicode_AsUTF8( res );
         //SCRUTE(astr);
         files.append(astr);
       }
@@ -2617,8 +2617,8 @@ void PyModuleHelper::internalDumpPython( QStringList& files )
         int size = PyList_Size( res );
         for ( int i = 0; i < size; i++ ) {
           PyObject* value = PyList_GetItem( res, i );
-          if( value && PyString_Check( value ) ) {
-            files.append( PyString_AsString( value ) );
+          if( value && PyUnicode_Check( value ) ) {
+            files.append( PyUnicode_AsUTF8( value ) );
           }
         }
       }
@@ -2760,8 +2760,8 @@ QString PyModuleHelper::internalEngineIOR() const
       }
       else {
         // parse the return value, result chould be string
-        if ( PyString_Check( res ) ) {
-          ior = PyString_AsString( res );
+        if ( PyUnicode_Check( res ) ) {
+          ior = PyUnicode_AsUTF8( res );
         }
       }
     }
index c68378d4b035a0a284af8b0bf120a56acaa1837c..0b3c1a2fe7df80ef797bdf9f158474453c6b3d96 100755 (executable)
@@ -49,7 +49,7 @@ INCLUDE_DIRECTORIES(
 
 # swig flags
 SET_SOURCE_FILES_PROPERTIES(libSALOME_Swig.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(libSALOME_Swig.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+SET_SOURCE_FILES_PROPERTIES(libSALOME_Swig.i PROPERTIES SWIG_FLAGS "-py3")
 SET_SOURCE_FILES_PROPERTIES(libSALOME_SwigPYTHON_wrap.cxx PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
 
 # additional preprocessor / compiler flags
index 109b56ffc328a651a58270d2312f7ba4751e8b29..a2b032fd8621d93cea342266098910905502504d 100755 (executable)
@@ -50,7 +50,7 @@ myVerNb = 200
 k={}
 for j in range(0,myHorNb):
    k[j] = j*10+1
-ARealTable.AddRow(k.values())
+ARealTable.AddRow(list(k.values()))
 ARealTable.SetRowTitle(1, "Frequency")
 ARealTable.SetRowUnit(1, "Hz")
 
@@ -60,7 +60,7 @@ for i in range(1,myVerNb+1):
          k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
       else:
          k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 
-   ARealTable.AddRow(k.values())
+   ARealTable.AddRow(list(k.values()))
    ARealTable.SetRowTitle(i+1, "Power " + str(i))
    ARealTable.SetRowUnit(i+1, "Wt")
 ARealTable.SetTitle("Very useful data")
index dafddcd9e6ab2e3562cd652ce6262b5e946268e9..6a4b0b69aaabfa2c57f097c2fed763a860afa012 100755 (executable)
@@ -30,22 +30,22 @@ myBuilder = myStudy.NewBuilder()
 
 
 obj1 = myStudy.FindObjectID("0:1")
-if obj1 is None: print "Is null obj1 "
-else: print obj1.GetID()
+if obj1 is None: print("Is null obj1 ")
+else: print(obj1.GetID())
 
 obj2 = myBuilder.NewObject(obj1)
-print "Obj2 ID = "+obj2.GetID()
+print("Obj2 ID = "+obj2.GetID())
 
 myBuilder.Addreference(obj1, obj2)
 
 (f, obj3) = obj1.ReferencedObject()
 
-print "Ref obj ID = "+obj3.GetID()
+print("Ref obj ID = "+obj3.GetID())
 
 
 myBuilder.RemoveReference(obj1)
 
 (f, obj4) = obj1.ReferencedObject()
 
-print "Ref is found ", f
+print("Ref is found ", f)
  
\ No newline at end of file
index 780c3c7aeaf14c7f52869a334d2644d42f922b26..812b21e47327882c71add2835798f5617e89f89c 100755 (executable)
@@ -72,17 +72,17 @@ l={}
 for j in range(0,20):
    k[j] = j*10+1
    l[j] = "C"+str(j+1)
-ARealTable.AddRow(k.values())
+ARealTable.AddRow(list(k.values()))
 ARealTable.SetRowTitle(1, "Row 0")
 ARealTable.SetRowUnit(1, "Hz")
-ARealTable.SetColumnTitles(l.values())
+ARealTable.SetColumnTitles(list(l.values()))
 for i in range(1,11):
    for j in range(1,21):
       if j % 2 == 1:
          k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
       else:
          k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 
-   ARealTable.AddRow(k.values())
+   ARealTable.AddRow(list(k.values()))
    ARealTable.SetRowTitle(i+1, "Row " + str(i))
    ARealTable.SetRowUnit(i+1, "Wt")
 ARealTable.SetTitle("TEST table of real")
index 372d3e6ed69c3d038f61e6c2e8e10ed71f7f8b01..3724dd562f3ecacc73f235f0909820712faed73c 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-
+//  Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+//  Date   : 22/06/2007
+//
 #include "SUITApp_init_python.hxx"
 #include <QString>
 
-bool SUIT_PYTHON::initialized = false;
+#if PY_VERSION_HEX < 0x03050000
+static char*
+Py_EncodeLocale(const wchar_t *arg, size_t *size)
+{
+       return _Py_wchar2char(arg, size);
+}
+static wchar_t*
+Py_DecodeLocale(const char *arg, size_t *size)
+{
+       return _Py_char2wchar(arg, size);
+}
+#endif
+
+bool SUIT_PYTHON::initialized                       = false;
 
 void SUIT_PYTHON::init_python(int argc, char **argv)
 {
@@ -29,9 +44,17 @@ void SUIT_PYTHON::init_python(int argc, char **argv)
   {
     return;
   }
-  Py_SetProgramName(argv[0]);
+
+  wchar_t **changed_argv = new wchar_t*[argc]; // Setting arguments
+  for (int i = 0; i < argc; i++)
+  {
+   changed_argv[i] = Py_DecodeLocale(argv[i], NULL);    
+  }
+
+  Py_SetProgramName(changed_argv[0]);
   Py_Initialize(); // Initialize the interpreter
-  PySys_SetArgv(argc, argv);
+
+  PySys_SetArgv(argc, changed_argv);
   PyRun_SimpleString("import threading\n");
   // VSR (22/09/2016): This is a workaround to prevent invoking qFatal() from PyQt5
   // causing application aborting
index c128547414e94297ddb015ef0ad369db1e4f5ca5..2dec0819855955b2435cb3abdad9e360e75bb22f 100644 (file)
@@ -272,7 +272,7 @@ void SalomeApp_Application::start()
 
               script.remove( QRegExp("^python.*[\\s]+") );
               QString cmd = script+" "+args;
-              QString command = QString( "execfile(r\"%1\")" ).arg(cmd.trimmed());
+              QString command = QString( "exec(open(\"%1\").read())" ).arg(cmd.trimmed());
               pyConsole->exec(command);
             }
           } // end for loop on pyfiles QStringList
@@ -497,7 +497,7 @@ void SalomeApp_Application::onNewWithScript()
   {
     onNewDoc();
 
-    QString command = QString("execfile(r\"%1\")").arg(aFile);
+    QString command = QString("exec(open(\"%1\").read())").arg(aFile);
 
 #ifndef DISABLE_PYCONSOLE
     PyConsole_Console* pyConsole = pythonConsole();
@@ -924,7 +924,7 @@ void SalomeApp_Application::onLoadScript( )
 
   if ( !aFile.isEmpty() )
   {
-    QString command = QString("execfile(r\"%1\")").arg(aFile);
+    QString command = QString("exec(open(\"%1\").read())").arg(aFile);
 
 #ifndef DISABLE_PYCONSOLE
     PyConsole_Console* pyConsole = pythonConsole();
@@ -1958,7 +1958,7 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript,
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
 
   // load study from the temporary directory
-  QString command = QString( "execfile(r\"%1\")" ).arg( theDumpScript );
+  QString command = QString( "exec(open(\"%1\").read())" ).arg( theDumpScript );
 
 #ifndef DISABLE_PYCONSOLE
   PyConsole_Console* pyConsole = app->pythonConsole();
index fe94de0deca02137be231cd7c681d4fbd6b5c580..71644587752f3507615f5cdebba8e86cb0f8698e 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+#ifndef DISABLE_PYCONSOLE
+  #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
+#endif
+
 #include "SalomeApp_Study.h"
 
 #include "SalomeApp_Module.h"
 
 #include <LightApp_Displayer.h>
 
-#ifndef DISABLE_PYCONSOLE
-  #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
-#endif
-
 #include "utilities.h"
 
 #include "SALOMEDS_Tool.hxx"
index 0b25d80420d548b186f2971d2ab3e02a0b8e6e46..44ad7ace57b6badee2e046ebdeea2cd77b439f76 100644 (file)
@@ -21,7 +21,7 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-import sys, os,signal,string,commands
+import sys, os,signal,string,subprocess
 import runSalome
 import orbmodule
 import TestKiller
index f93ba12a74bf2c69c355988cd8ac674bb39b2228..451b944e445e003d018c5468f72c35435e9b6b53 100755 (executable)
@@ -271,13 +271,13 @@ def runSalomeShellSession(context):
     elif os.path.exists("/usr/bin/xterm"):
       command = 'xterm -T "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
     else:
-      print "Neither xterm nor gnome-terminal nor konsole is installed."
+      print("Neither xterm nor gnome-terminal nor konsole is installed.")
 
     if command is not "":
       try:
         subprocess.check_call(command, shell = True)
-      except Exception, e:
-        print "Error: ",e
+      except Exception as e:
+        print("Error: ",e)
 
 
 salome_pluginsmanager.AddFunction('SALOME shell session',
index 2252fff75f32c1b11559566fc010b81d216a0e6b..c7902de38f64ab74ded16520ee6ea3988e224cf8 100644 (file)
@@ -1,5 +1,4 @@
-# -*- coding: utf-8 -*-
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (C) 2010-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
index e121161c0fad399615103c9c29b53c09733e54a3..44e7ec508f351f8ab9d44114f54b4d2821c48343 100644 (file)
@@ -32,7 +32,7 @@ def createGeometry(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_W
     This function creates the geometry on the specified study and with
     given parameters.
     '''
-    print "TUBE: creating the geometry ..."
+    print("TUBE: creating the geometry ...")
     geompy = geomtools.getGeompy()
 
     radius_ext = radius
@@ -54,7 +54,7 @@ def createGeometryWithPartition(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, wi
     # meshing algorithm.
     geompy = geomtools.getGeompy()
 
-    print "TUBE: creating a partition ..."
+    print("TUBE: creating a partition ...")
     toolPlane = geompy.MakeFaceHW(2.1*length,2.1*radius,3)
     partition = geompy.MakePartition([shape], [toolPlane], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
     entry = geompy.addToStudy( partition, "TubeWithPartition" )
@@ -62,7 +62,7 @@ def createGeometryWithPartition(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, wi
     
 def createMesh(shape):
     '''This function creates the mesh of the specified shape on the current study'''
-    print "TUBE: creating the mesh ..."
+    print("TUBE: creating the mesh ...")
     import SMESH
     from salome.smesh import smeshBuilder
     smesh = smeshBuilder.New()
@@ -102,7 +102,7 @@ def exportModel(mesh, filename):
     '''
     This exports the mesh to the specified filename in the med format
     '''
-    print "TUBE: exporting mesh to file %s ..."%filename
+    print("TUBE: exporting mesh to file %s ..."%filename)
     import SMESH
     mesh.ExportMED(filename, 0, SMESH.MED_V2_2, 1 )
 
index 84f5a418be261d05d97ab48487b82726c8787218..3716205b1f186ef76e357e40dedcbff273795f66 100644 (file)
@@ -68,7 +68,7 @@ class TubeDialog(TubeDialog_UI):
             length=eval(str(self.txtLength.text()))
             width=eval(str(self.txtWidth.text()))
         except:
-            print "pb a la saisie"
+            print("pb a la saisie")
 
         return radius, length, width
 
@@ -103,7 +103,7 @@ def TEST_getData_synchrone():
     tubedialog.exec_()
     if tubedialog.wasOk():
         radius, length, width = tubedialog.getData()
-        print radius, length, width
+        print(radius, length, width)
 
 
 def main( args ):
index e4ffb88f40c0a0367f66c6db6f092f62f7414534..c6bc59f1ecb0cc5207aa4df567daf3709a9c0ad6 100644 (file)
@@ -102,14 +102,14 @@ plugins={}
 current_plugins_manager=None
 
 def initialize(module,name,basemenuname,menuname):
-  if not plugins.has_key(name):
+  if name not in plugins:
     if module:
       plugins[name]={}
     else:
       plugins[name]=[]
   if module:
     d=sgPyQt.getDesktop()
-    if plugins[name].has_key(d):return
+    if d in plugins[name]:return
     plugins[name][d]=PluginsManager(module,name,basemenuname,menuname)
   else:
     plugins[name].append(PluginsManager(module,name,basemenuname,menuname))
@@ -147,8 +147,8 @@ logger=Logger("PluginsManager") #,color=GREEN)
 class PluginsManager:
     def __init__(self,module,name,basemenuname,menuname):
         self.name=name
-        self.basemenuname=unicode(basemenuname, "utf-8")
-        self.menuname=unicode(menuname, "utf-8")
+        self.basemenuname=basemenuname
+        self.menuname=menuname
         self.module=module
         self.registry={}
         self.handlers={}
@@ -162,13 +162,16 @@ class PluginsManager:
         # MODULES plugins are supposed to be located in the
         # installation folder of the module, in the subdirectory
         # "share/salome/plugins". We first look for these directories.
+        searched = []
         for key in os.environ.keys():
           if key.endswith("_ROOT_DIR"):
             rootpath=os.environ[key]
             dirpath=os.path.join(rootpath,PLUGIN_PATH_PATTERN)
-            if os.path.isdir(dirpath) and dirpath not in self.plugindirs:
+            if os.path.isdir(dirpath) and dirpath not in self.plugindirs + searched:
               logger.debug("Looking for plugins in the directory %s ..."%dirpath)
               walktree(dirpath,self.analyseFile)
+              if dirpath not in self.plugindirs and dirpath not in searched:
+                searched.append(dirpath)
 
         # USER plugins directory
         user_dir = os.path.expanduser("~/.config/salome/Plugins")
@@ -274,7 +277,7 @@ class PluginsManager:
               sys.path.insert(0,directory)
               logger.debug("The directory %s has been added to PYTHONPATH"%directory)
             try:
-              execfile(plugins_file,globals(),{})
+              exec(compile(open(plugins_file).read(), plugins_file, 'exec'),globals(),{})
             except:
               logger.fatal("Error while loading plugins from file %s"%plugins_file)
               traceback.print_exc()
@@ -298,7 +301,7 @@ class PluginsManager:
                 submenus[str(menu.title())]=menu
             while len(names) > 1:
               name=names.pop(0)
-              if submenus.has_key(name):
+              if name in submenus:
                 amenu=submenus[name]
               else:
                 amenu=QMenu(name,parentMenu)
index ea144e9a96cb5e33c8361aa04a21094603f751d3..c8465bfd0b5d1e01b283b6442b5466a9e85c2c91 100755 (executable)
 //  Author : Paul RASCLE, EDF
 //  Module : SALOME
 
+#include <Container_init_python.hxx>
 #include <SALOME_NamingService.hxx>
 #include <SALOME_ModuleCatalog_impl.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
 #include <SALOME_Event.h>
 
-#include <Container_init_python.hxx>
 #include <ConnectionManager_i.hxx>
 #include <RegistryService.hxx>
 
index 76be5e6a6f26a6d034a633f9d622eea9ce1a99f1..f5670e52ed421de823adfb4d4897269054903ea7 100644 (file)
@@ -104,13 +104,13 @@ class PlotController(object):
     if model is None or self._blockNotifications:
       return
     
-    if not self._modelViews.has_key(model):
+    if model not in self._modelViews:
       return
     
     for view in self._modelViews[model]:
       method = "on%s" % what
       if what != "" and what is not None and hasattr(view, method):
-        exec "view.%s()" % method
+        exec("view.%s()" % method)
       elif hasattr(view, "update"):
         # Generic update:
         view.update()
@@ -268,12 +268,12 @@ class PlotController(object):
         return -1
 
     ps = control._plotManager.removeXYPlotSet(plot_set_id)
-    for _, crv in ps._curves.items():
+    for _, crv in list(ps._curves.items()):
       control.removeModelListeners(crv)
     control.removeModelListeners(ps)
     psets = control._plotManager._plotSets 
     if len(psets):
-      control._plotManager.setCurrentPlotSet(psets.keys()[-1])
+      control._plotManager.setCurrentPlotSet(list(psets.keys())[-1])
     return plot_set_id
   
   @classmethod
@@ -282,7 +282,7 @@ class PlotController(object):
       gc.collect()
       import resource
       m = resource.getrusage(resource.RUSAGE_SELF)[2]*resource.getpagesize()/1e6
-      print "** Used memory: %.2f Mb" % m
+      print("** Used memory: %.2f Mb" % m)
   
   @classmethod
   def DeleteCurrentItem(cls):
@@ -397,7 +397,7 @@ class PlotController(object):
     """ @return the first plot set whose name matches the provided name. Otherwise returns -1
     """ 
     pm = cls.GetInstance()._plotManager
-    for _, ps in pm._plotSets.items():
+    for _, ps in list(pm._plotSets.items()):
       if ps._title == name:
         return ps.getID()
     return -1
@@ -407,10 +407,10 @@ class PlotController(object):
     """ @return two lists: plot set names, and corresponding plot set IDs
     """
     pm = cls.GetInstance()._plotManager
-    it = pm._plotSets.items()
+    it = list(pm._plotSets.items())
     ids, inst, titles = [], [], []
     if len(it):  
-      ids, inst = zip(*it)        
+      ids, inst = list(zip(*it))        
     if len(inst):
       titles = [i.getTitle() for i in inst]
     return list(ids), titles
@@ -477,7 +477,7 @@ class PlotController(object):
     @return True if plot_set_id is the identifier of a valid and existing plot set.
     """
     control = cls.GetInstance()
-    return control._plotManager._plotSets.has_key(plot_set_id)
+    return plot_set_id in control._plotManager._plotSets
 
   @classmethod
   def GetSalomeViewID(cls, plot_set_id):
@@ -535,7 +535,7 @@ class PlotController(object):
       raise ValueError("Invalid marker: '%s'" % marker)
     
     cont = cls.GetInstance()
-    for mod, views in cont._modelViews.items():
+    for mod, views in list(cont._modelViews.items()):
       if isinstance(mod, CurveModel) and mod.getID() == crv_id:
         for v in views:
           if isinstance(v, CurveView):
@@ -566,11 +566,11 @@ class PlotController(object):
     from XYView import XYView
     
     cont = cls.GetInstance()
-    for mod, views in cont._modelViews.items():
+    for mod, views in list(cont._modelViews.items()):
       if isinstance(mod, XYPlotSetModel) and mod.getID() == ps_id:
         for v in views:
           if isinstance(v, XYView):
-            exec "v.%s(*args, **kwargs)" % func
+            exec("v.%s(*args, **kwargs)" % func)
             found = True
     if not found:
       raise Exception("Invalid plot set ID or plot set currently not displayed (ps_id=%d)!" % ps_id)
index fd0b521e3c6415bbdc6d002946ab765605c0f04d..62d412f2d632bb892c6ba1a46c09a5c2392f994b 100644 (file)
@@ -10,11 +10,11 @@ try:
   import matplotlib
   matplotlib.use('Qt4Agg')
   import matplotlib.pyplot as plt  # must come after the PySide/PyQt4 switch!
-  plt.rcParams['font.sans-serif'].insert(0, u"DejaVu Sans")
+  plt.rcParams['font.sans-serif'].insert(0, "DejaVu Sans")
 except:
-  print "Warning: could not switch matplotlib to 'Qt4agg' backend. Some characters might be displayed improperly!"
+  print("Warning: could not switch matplotlib to 'Qt4agg' backend. Some characters might be displayed improperly!")
 
-from PlotController import PlotController
+from .PlotController import PlotController
 from TableModel import TableModel
 from CurveModel import CurveModel
 from PlotManager import PlotManager
index 87f8e76c2d992cb5c3cd332a22630e944d6bd293..684858174ef83b5b2aae16de2e57d52cb7cea9bd 100644 (file)
@@ -55,7 +55,7 @@ class Logger(object):
 
     @classmethod
     def __log(cls, typ, msg):
-        print "%s: %s" % (typ, msg)
+        print("%s: %s" % (typ, msg))
       
 def trQ(tag, context="CURVEPLOT"):
   """ @return a QString read from the translation file """
index 665c2a7631f9ffd949356016f0f56d3fb2ff8588..b874737e0dd62ee2de7608ef4b35e7a8e46889dd 100644 (file)
@@ -16,7 +16,7 @@ class PlotManager(Model):
     return len(self._plotSets) == 0
   
   def setCurrentPlotSet(self, plotSetID, silent=False):
-    if not self._plotSets.has_key(plotSetID) and plotSetID != -1:
+    if plotSetID not in self._plotSets and plotSetID != -1:
       raise ValueError("Invalid plot set ID (%d)!" % plotSetID)
     self._currentPlotSet = self._plotSets.get(plotSetID, None)
     if not silent:
@@ -26,8 +26,8 @@ class PlotManager(Model):
     return self._currentPlotSet
   
   def getPlotSetContainingCurve(self, curveID):
-    for ps in self._plotSets.values():
-      if ps._curves.has_key(curveID):
+    for ps in list(self._plotSets.values()):
+      if curveID in ps._curves:
         return ps
     return None
   
@@ -67,8 +67,8 @@ class PlotManager(Model):
   
   def removeXYPlotSet(self, plotSetID):
     Logger.Debug("====> PlotManager::removeXYPlotSet() %d" % plotSetID)
-    if not self._plotSets.has_key(plotSetID):
-      print self._plotSets
+    if plotSetID not in self._plotSets:
+      print(self._plotSets)
       raise ValueError("Plot set ID (%d) not found for deletion!" % plotSetID)
     ps = self._plotSets.pop(plotSetID)
     if self._currentPlotSet is ps:
index 18bb60e2f9b56c707f43884fdb328f2acb1fb82e..2edacfb9e14918cc06a73fb3fbddaf614d15c37a 100644 (file)
@@ -26,7 +26,7 @@ class XYPlotSetModel(Model):
     return self._title
       
   def setCurrentCurve(self, curveID, silent=False):
-    if not self._curves.has_key(curveID) and curveID != -1:
+    if curveID not in self._curves and curveID != -1:
       raise ValueError("Invalid curve ID (%d)!" % curveID)
     self._currentCurve = self._curves.get(curveID, None)
     if not silent:
@@ -41,7 +41,7 @@ class XYPlotSetModel(Model):
       self.notifyChange("AddCurve")
   
   def removeCurve(self, curveID, silent=False):
-    if not self._curves.has_key(curveID):
+    if curveID not in self._curves:
       raise ValueError("Curve ID (%d) not found for deletion!" % curveID)
     c = self._curves.pop(curveID)
     if self._currentCurve is c:
index ef46e4b6d0775c89076db04528dee5a81d6873b6..1cba014b11df652d919d305268ad076f34e42b49 100644 (file)
@@ -8,12 +8,12 @@ try:
     raise Exception
   import PyQt4
   _use_pyqt = True
-  print "Using PyQt4 run-time ..."
+  print("Using PyQt4 run-time ...")
 except:
   try:
     import PySide
     _use_pyqt = False
-    print "Using PySide run-time ..."
+    print("Using PySide run-time ...")
   except:
     raise Exception("Neither PyQt4 nor PySide could be imported!")
 
@@ -24,7 +24,7 @@ try:
   if _use_pyqt:  back = 'PyQt4'
   else:          back = 'PySide'
   matplotlib.rcParams['backend.qt4'] = back
-  print "Matplotlib found - Set matplotlib backend to '%s'!" % back 
+  print("Matplotlib found - Set matplotlib backend to '%s'!" % back) 
 except:
   # No matplotlib, silently discard err message.
   pass
index 3f9565b8eb9ac8b5ed678cb6b81179d7f1c9de1f..6cc1465107f53c5831b8dbecac4f4f4cb8f7e9b2 100644 (file)
@@ -2,6 +2,6 @@ from . import _use_pyqt
 if _use_pyqt:
   from PyQt4.uic import loadUi as loadUiGen
 else: 
-  from pyside_dynamic import loadUi as loadUiGen
+  from .pyside_dynamic import loadUi as loadUiGen
 
 
index ad2886efdd37925b17c05e6bd4ec5b7459a5cbeb..4097dedf0dd4f5e001e0d264cf1b95aa0b78ffcd 100755 (executable)
@@ -51,7 +51,7 @@ def main(args) :
     trans = QTranslator()
     for f in ts_files:
       if not trans.load(f):
-        print "could not load translation %s!" % f
+        print("could not load translation %s!" % f)
     app.installTranslator(trans)
     dw = app.desktop()
     x, y = dw.width()*0.25, dw.height()*0.7
index 361b0d1e7dbfc96d3de19512650ec3c419c827a3..e9cfc9aaa4fab91a0433ab67af2b8cb6407cbe27 100644 (file)
@@ -72,7 +72,7 @@ class PlotTestBase(unittest.TestCase):
       self.tmpBaselineDir = os.path.join(tempfile.gettempdir(), "curveplot_baselines")
       if not os.path.isdir(self.tmpBaselineDir):
         os.mkdir(self.tmpBaselineDir)
-      print "### Rebuilding base lines. Reference files will be saved to '%s'" % self.tmpBaselineDir
+      print("### Rebuilding base lines. Reference files will be saved to '%s'" % self.tmpBaselineDir)
        
     PlotController.WITH_CURVE_BROWSER = True
     XYView._DEFAULT_LEGEND_STATE = True   # always show legend by default
@@ -146,7 +146,7 @@ class PlotTestBase(unittest.TestCase):
     if not ret:
       # Keep file if assert is false
       self.keepDir = True
-      print "[%s] -- Failed screenshot equality, or unable to open baseline file - directory is kept alive: %s" % (self.getTestName(), self.tmpDir)
+      print("[%s] -- Failed screenshot equality, or unable to open baseline file - directory is kept alive: %s" % (self.getTestName(), self.tmpDir))
     return ret 
   
   def showTabWidget(self):
index 8d72fd675a75e41fddcca6a7e956ca5f8e32c1e4..142fcf64f54d1befd02367d44f2793651c8ef48c 100644 (file)
@@ -177,21 +177,21 @@ class TestDesktop(QMainWindow):
       for _ in range(nC):
         x, y = self.__generateRandomData(1000)
         lx.append(x); ly.append(y)
-      print "Done generating"
+      print("Done generating")
       from time import time
       t0 = time()
       curveplot.LockRepaint()
       for i in range(nC): 
         curveplot.AddCurve(lx[i], ly[i], append=True)
       curveplot.UnlockRepaint()
-      print "Elapsed: %.2f" % ( time() - t0)
+      print("Elapsed: %.2f" % ( time() - t0))
 
     def clearPlotSet(self):
       curveplot.ClearPlotSet()
       
     def addPS(self):
       # Also a test for unicode!
-      curveplot.AddPlotSet(u'ça m embête')
+      curveplot.AddPlotSet('ça m embête')
       
     def addTab(self):
       pass
@@ -216,12 +216,12 @@ class TestDesktop(QMainWindow):
     @Slot()
     def memPrint(self):
       i, t = curveplot.GetAllPlotSets()
-      print zip(i, t)
+      print(list(zip(i, t)))
       new_id = curveplot.CopyCurve(curve_id=0, plot_set_id=1)
-      print "created  curve: %d" % new_id
+      print("created  curve: %d" % new_id)
       import resource
       m = resource.getrusage(resource.RUSAGE_SELF)[2]*resource.getpagesize()/1e6
-      print "** Used memory: %.2f Mb" % m
+      print("** Used memory: %.2f Mb" % m)
       if self.cnt >= 0 and self.cnt < self.MAX_CNT:
         self.cnt += 1
         QTimer.singleShot(self.timeLap, self, SLOT("curveSameFig()"))
index 204406cd4d801d0456dcb17698f22a555d740fb2..3058925ffd7d7a8b49b6b16bf7b3126f2fdedb1e 100644 (file)
@@ -148,7 +148,7 @@ class PlotTest(PlotTestBase):
   def testAddCurve(self):
     x, y = self.generateSine()
     tw = self.showTabWidget()
-    PlotController.AddCurve(x, y, curve_label="My curve", x_label=u"Lèés X (unicode!)", y_label=u"Et des Å·", append=False)
+    PlotController.AddCurve(x, y, curve_label="My curve", x_label="Lèés X (unicode!)", y_label="Et des Å·", append=False)
     self.assertTrue(self.areScreenshotEqual(tw))
       
   def testAddCurveAppend(self):
@@ -304,21 +304,21 @@ class PlotTest(PlotTestBase):
   def testSetLabelX(self):
     tw = self.showTabWidget()
     ps_id = PlotController.AddPlotSet("My plotset")
-    PlotController.SetXLabel(u"The X-s Ã©Ã ", ps_id)
+    PlotController.SetXLabel("The X-s Ã©Ã ", ps_id)
     self.assertTrue(self.areScreenshotEqual(tw))
 
   def testSetLabelY(self):
     tw = self.showTabWidget()
     ps_id = PlotController.AddPlotSet("My plotset")
-    PlotController.SetYLabel(u"Tutu", ps_id)
-    PlotController.SetYLabel(u"The Y-s uûàç", ps_id)
+    PlotController.SetYLabel("Tutu", ps_id)
+    PlotController.SetYLabel("The Y-s uûàç", ps_id)
     self.assertTrue(self.areScreenshotEqual(tw))
 
   def testSetPlotSetTitle(self):
     tw = self.showTabWidget()
     ps_id = PlotController.AddPlotSet("tutu")
     PlotController.AddPlotSet("tata")
-    PlotController.SetPlotSetTitle(u"un titre Ã Ã©", ps_id)
+    PlotController.SetPlotSetTitle("un titre Ã Ã©", ps_id)
     PlotController.SetCurrentPlotSet(ps_id)
     self.assertTrue(self.areScreenshotEqual(tw))
         
@@ -354,7 +354,7 @@ class PlotTest(PlotTestBase):
       dlg_test.showLegendCheckBox.setChecked(True)
       return True  
     dlg_test.exec_ = fun
-    t = PlotController.GetInstance()._curveTabsView._XYViews.items()
+    t = list(PlotController.GetInstance()._curveTabsView._XYViews.items())
     t[0][1].onSettings(dlg_test=dlg_test)  
     self.assertTrue(self.areScreenshotEqual(tw))
  
@@ -389,7 +389,7 @@ class PlotTest(PlotTestBase):
       dlg_test.showLegendCheckBox.setChecked(True)
       return True  
     dlg_test.exec_ = fun
-    t = PlotController.GetInstance()._curveTabsView._XYViews.items()
+    t = list(PlotController.GetInstance()._curveTabsView._XYViews.items())
     t[0][1].onSettings(dlg_test=dlg_test)  
     self.assertTrue(self.areScreenshotEqual(tw))
     
index bd6aac2563ea06615f7b34c00600f67f9bfa5ee2..d264618953c992532a1d0eb768a50fee9c4f8f94 100644 (file)
@@ -53,10 +53,10 @@ class PlotSettings(QtGui.QDialog):
     return pix
 
   def accept(self):
-    xminText = unicode(self.axisXMinEdit.text())
-    xmaxText = unicode(self.axisXMaxEdit.text())
-    yminText = unicode(self.axisYMinEdit.text())
-    ymaxText = unicode(self.axisYMaxEdit.text())
+    xminText = str(self.axisXMinEdit.text())
+    xmaxText = str(self.axisXMaxEdit.text())
+    yminText = str(self.axisYMinEdit.text())
+    ymaxText = str(self.axisYMaxEdit.text())
     if (yminText == "" or ymaxText == "") :
       QtGui.QMessageBox.critical(self, "Plot settings", "A field \"YMin\" or \"YMax\" is empty")
     else :
index ad2facd56faf3f6c397764d8525cbe59200db96f..df296b60a68525ebdbe8295ac27efd748f17ebdb 100644 (file)
@@ -35,11 +35,11 @@ class CurveBrowserView( View, CurveTreeDockWidget) :
         plotSets = self._model._plotSets
             
         # The second (hidden) column in the tree bares the ID of the object and its nature (plotset or curve)
-        for p in plotSets.values():
-          item = QtGui.QTreeWidgetItem([unicode(p.getTitle()), unicode(p.getID()) + '_set'])
+        for p in list(plotSets.values()):
+          item = QtGui.QTreeWidgetItem([str(p.getTitle()), str(p.getID()) + '_set'])
           treeWidget.addTopLevelItem(item)
-          for c in p._curves.values():
-            chld = QtGui.QTreeWidgetItem([unicode(c.getTitle()), unicode(c.getID()) + '_crv'])
+          for c in list(p._curves.values()):
+            chld = QtGui.QTreeWidgetItem([str(c.getTitle()), str(c.getID()) + '_crv'])
             item.addChild(chld)
           
         treeWidget.expandAll()
index 3454837c6bd96147d3ccb54d2fe3723c1d953abd..9189239f9e66a386420c57ff10ae60485ca89760 100644 (file)
@@ -32,7 +32,7 @@ class CurveTabsView(View):
   def mapModId2ViewId(self):
     """ Gives a map from model ID (the model behind the XYView) to view ID
     """
-    lst = [(v._model.getID(), view_id) for view_id, v in self._XYViews.items()]
+    lst = [(v._model.getID(), view_id) for view_id, v in list(self._XYViews.items())]
     return dict(lst)
   
   def update(self):
@@ -44,7 +44,7 @@ class CurveTabsView(View):
     
     # Check list of tabs:
     set_mod = set(self._model._plotSets.keys())
-    set_view = set([ v._model.getID() for v in self._XYViews.values() ])
+    set_view = { v._model.getID() for v in list(self._XYViews.values()) }
     mp = self.mapModId2ViewId()
     
     # Deleted/Added curves:
@@ -62,7 +62,7 @@ class CurveTabsView(View):
       newViews.append(self.createXYView(self._model._plotSets[a]))
     
     # Now update all tabs individually (this will trigger creation of new ones if not already there):
-    for v in self._XYViews.values() + newViews:
+    for v in list(self._XYViews.values()) + newViews:
       # The update on newViews will trigger the SALOME view creation:
       v.update() 
     
index 42ad149ece2560b15b8c9d61debbe980d7a5d989..ba3ca573148c3977f275c86af9847e1d47c43655 100644 (file)
@@ -158,7 +158,7 @@ class XYView(View):
     if event.mouseevent.button == 1:
       selected_id = -1
       a = event.artist
-      for crv_id, cv in self._curveViews.items():
+      for crv_id, cv in list(self._curveViews.items()):
         if cv._mplLines[0] is a:
           selected_id = crv_id
       # Use the plotmanager so that other plot sets get their current reset:
@@ -301,10 +301,10 @@ class XYView(View):
       return
     action = self._curveActionGroup.checkedAction()
     if action is self._pointsAction :
-      for crv_view in self._curveViews.values():
+      for crv_view in list(self._curveViews.values()):
         crv_view.setLineStyle("None")
     elif action is self._linesAction :
-      for crv_view in self._curveViews.values():
+      for crv_view in list(self._curveViews.values()):
         crv_view.setLineStyle("-")
     else :
       raise NotImplementedError
@@ -682,7 +682,7 @@ class XYView(View):
       point = event.canvas.mapToGlobal(QtCore.QPoint(event.x,canvasSize.height()-event.y))
       self._popupMenu.exec_(point)
     else :
-      print "Press event on the other button"
+      print("Press event on the other button")
     #if event.button == 3 :
     #  canvasSize = event.canvas.geometry()
     #  point = event.canvas.mapToGlobal(QtCore.QPoint(event.x,canvasSize.height()-event.y))
@@ -690,13 +690,13 @@ class XYView(View):
     #  self._popupMenu.show()
 
   def onMotionEvent(self, event):
-    print "OnMotionEvent ",event.button
+    print("OnMotionEvent ",event.button)
     #if event.button == 3 :
     #  event.button = None
     #  return True
 
   def onReleaseEvent(self, event):
-    print "OnReleaseEvent ",event.button
+    print("OnReleaseEvent ",event.button)
     #if event.button == 3 :
     #  event.button = None
     #  return False
index 26f8b1cdcde290f2e178642b4d93d7df0ec65d6e..6a38b7c5c72bdbc0c879e7a6c3d0d94e7f0f960a 100644 (file)
@@ -22,8 +22,8 @@
 // File   : PyConsole_Console.cxx
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 
-#include "PyConsole_Console.h"
 #include "PyConsole_Interp.h"
+#include "PyConsole_Console.h"
 #include "PyConsole_Editor.h"
 
 #include <QAction>
index 4c3df75f0225ff9314a2d5c69cbf917f3243f67c..d0b03e59fa9ccec258f7d9c391262e45e0752190 100644 (file)
@@ -88,8 +88,8 @@
   - <Ctrl><Tab>          : undoes auto-completion
 */
 
-#include "PyConsole_Editor.h"
 #include "PyConsole_Interp.h"
+#include "PyConsole_Editor.h"
 #include "PyConsole_Event.h"
 #include "PyInterp_Dispatcher.h"
 #include "PyConsole_Request.h"
index 7224136868f91715b3d7d3edaecb490bcda37005..03948e1bf82ef766e47c8173aa196dc491943dcd 100644 (file)
@@ -131,13 +131,13 @@ bool PyConsole_Interp::runDirCommand( const QString& dirArgument, const QString&
       cmd.prepend( QString( "%1." ).arg( dirArgument ) );
     
     PyObject* str = PyRun_String( cmd.toStdString().c_str(), Py_eval_input, _global_context, _local_context );
-    if ( !str || str == Py_None || !PyString_Check( str ) )
+    if ( !str || str == Py_None || !PyUnicode_Check( str ) )
       {
         if ( !str )
           PyErr_Clear();
       }
     else {
-      docString = QString( PyString_AsString( str ) );
+      docString = QString( PyUnicode_AsUTF8( str ) );
     }
     Py_XDECREF( str );
   }
@@ -183,7 +183,7 @@ bool PyConsole_Interp::runDirAndExtract( const QString& dirArgument,
   for ( int i = 0; i < n; i++ ) {
     PyObject* it;
     it = PySequence_GetItem( plst, i );
-    QString s( PyString_AsString( it ) );
+    QString s( PyUnicode_AsUTF8( it ) );
     // if the method is not from swig, not static (guessed from the reg exp) and matches
     // what is already there
     if ( s.startsWith( startMatch ) ) {
index 434b73cd43ff1b13819320acf23f768f413042f0..543b8c960d67c9fba5b79dd2070683f0e1652679 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef PYCONSOLE_INTERP_H
 #define PYCONSOLE_INTERP_H
 
-#include "PyConsole.h"
 #include "PyInterp_Interp.h"
+#include "PyConsole.h"
 
 #include <QStringList>
 
index 200649073b1b9596541e719825ed09b1b153d990..677ddaf5343971c2fc8d7287c927da92e3e314ab 100644 (file)
@@ -26,7 +26,7 @@
 #include "PyInterp_Utils.h"
 
 #include <pythread.h>
-#include <cStringIO.h>
+//#include <cStringIO.h>
 #include <structmember.h>
 #include <string>
 #include <vector>
@@ -55,8 +55,7 @@ static PyObject*
 PyStdOut_write(PyStdOut *self, PyObject *args)
 {
   char *c;
-  int l;
-  if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
+  if (!PyArg_ParseTuple(args, "s",&c))
     return NULL;
   if(self->_cb==NULL) {
     if ( self->_iscerr )
@@ -93,8 +92,8 @@ static PyMemberDef PyStdOut_memberlist[] = {
 static PyTypeObject PyStdOut_Type = {
   /* The ob_type field must be initialized in the module init function
    * to be portable to Windows without using C++. */
-  PyObject_HEAD_INIT(NULL)
-  0,                            /*ob_size*/
+  PyVarObject_HEAD_INIT(NULL, 0)
+  /*0,*/                            /*ob_size*/
   "PyOut",                      /*tp_name*/
   sizeof(PyStdOut),             /*tp_basicsize*/
   0,                            /*tp_itemsize*/
@@ -136,6 +135,14 @@ static PyTypeObject PyStdOut_Type = {
   0,                            /*tp_new*/
   0,                            /*tp_free*/
   0,                            /*tp_is_gc*/
+  0,                            /*tp_bases*/
+  0,                            /*tp_mro*/
+  0,                            /*tp_cache*/
+  0,                            /*tp_subclasses*/
+  0,                            /*tp_weaklist*/
+  0,                            /*tp_del*/
+  0,                            /*tp_version_tag*/
+  0,                            /*tp_finalize*/
 };
 
 #define PyStdOut_Check(v)  ((v)->ob_type == &PyStdOut_Type)
@@ -242,9 +249,16 @@ void PyInterp_Interp::initPython()
 {
   if (!Py_IsInitialized()){
     // Python is not initialized
-    Py_SetProgramName(_argv[0]);
+    wchar_t **changed_argv = new wchar_t*[_argc]; // Setting arguments
+    size_t mbslen;
+    for (int i = 0; i < _argc; i++)
+    {
+      changed_argv[i] = Py_DecodeLocale(_argv[i], NULL);
+    }
+   
+    Py_SetProgramName(changed_argv[0]);
     Py_Initialize(); // Initialize the interpreter
-    PySys_SetArgv(_argc, _argv);
+    PySys_SetArgv(_argc, changed_argv);
 
     PyEval_InitThreads(); // Create (and acquire) the Python global interpreter lock (GIL)
     PyEval_SaveThread(); // release safely GIL
@@ -342,7 +356,7 @@ static int run_command(const char *command, PyObject * global_ctxt, PyObject * l
     return 1;
   }
   else {
-    PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,global_ctxt, local_ctxt));
+    PyObjWrapper r(PyEval_EvalCode((PyObject *)(void *)v,global_ctxt, local_ctxt));
     if(!r) {
       // Execution error. We return -1
       PyErr_Print();
index d47ff184697451fab277c7778f0c3da609aedc66..7ad22d962521bf792f4064d1f26b711b59750faa 100644 (file)
   #include <iostream>
 #endif
 
+#if PY_VERSION_HEX < 0x03050000
+static char*
+Py_EncodeLocale(const wchar_t *arg, size_t *size)
+{
+       return _Py_wchar2char(arg, size);
+}
+static wchar_t*
+Py_DecodeLocale(const char *arg, size_t *size)
+{
+       return _Py_char2wchar(arg, size);
+}
+#endif
+
 /**
  * \class PyLockWrapper
  * \brief Python GIL wrapper.
index 1fe6e8b21c4995b8627f94ebdaea75914743253f..b4ed2ac6ca0dfae53b05a2c258026b46f70e0531 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (C) 2010-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
@@ -80,25 +80,24 @@ salomeinclude_HEADERS       += __CLASSNAME__.h
 """ 
 
 if __name__ == "__main__":
-  from optparse import OptionParser
-  import shutil, fileinput
+  from argparse import ArgumentParser
 
   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",
+  parser = ArgumentParser( description = __descr_str )
+  parser.add_argument( "-n", action="store", default="TestDialog", dest="className", metavar="className",
+                       help="specify the name of the class (default is TestDialog)" )
+  parser.add_argument( "-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" )
+  parser.add_argument( "-v", "--verbose", action="store_true", default=True, dest="verbose",
+                       help="verbose mode" )
+  parser.add_argument( "-s", "--silent", action="store_false", dest="verbose",
+                       help="silent mode" )
 
-  (options, args) = parser.parse_args()
-  className = options.className
-  classType = options.classType
+  args = parser.parse_args()
+  className = args.className
+  classType = args.classType
 
   for ext in [".cxx", ".h", ".ui"]:
     file_dest = className + ext 
@@ -108,17 +107,19 @@ if __name__ == "__main__":
     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 CMakeLists.txt (or something like that): \n"
-      print __msg_str.replace( "__CLASSNAME__", className )
+     
+    with open(file_src, 'r', encoding='utf-8') as fi, \
+         open(file_dest, 'w', encoding='utf-8') as fo:
+                   for line in fi:
+                     line = line[:-1] 
+                     line = line.replace( "__CLASSNAME__", className )
+                     line = line + "\n"
+                     fo.write(line)
+                     pass
+
+    if args.verbose:
+      print("Note that the following directives should be present in your CMakeLists.txt (or something like that): \n")
+      print(__msg_str.replace( "__CLASSNAME__", className ))
       pass
   pass