Salome HOME
[EDF17049] : Porting to Python3
[modules/kernel.git] / src / KERNEL_PY / PyInterp.py
index 4831016687cf03d7242a218c612c490f580de171..e33625b6a73c0a365927ca724a8bc65880d91ffa 100755 (executable)
@@ -1,29 +1,31 @@
-#  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-# 
-#  This library is free software; you can redistribute it and/or 
-#  modify it under the terms of the GNU Lesser General Public 
-#  License as published by the Free Software Foundation; either 
-#  version 2.1 of the License. 
-# 
-#  This library is distributed in the hope that it will be useful, 
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-#  Lesser General Public License for more details. 
-# 
-#  You should have received a copy of the GNU Lesser General Public 
-#  License along with this library; if not, write to the Free Software 
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-# 
-#  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
+# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
 #
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 #  File   : PyInterp.py
 #  Author : Paul RASCLE, EDF
 #  Module : SALOME
 #  $Header$
-
+#
 import sys
 from omniORB import CORBA
 from LifeCycleCORBA import *
@@ -33,9 +35,10 @@ from SALOME_NamingServicePy import *
 
     #--------------------------------------------------------------------------
 
-def DumpComponent(Study, SO, offset):
-    it = Study.NewChildIterator(SO)
-    Builder = Study.NewBuilder()
+def DumpComponent(SO, offset):
+    global myStudy
+    it = myStudy.NewChildIterator(SO)
+    Builder = myStudy.NewBuilder()
     while it.More():
         CSO = it.Value()
         it.Next()
@@ -48,7 +51,7 @@ def DumpComponent(Study, SO, offset):
             while ofs <= offset:
                 a = a + "--"
                 ofs = ofs +1
-            print a + ">" + CSO.GetID() + " " + t_name[1]
+            print(a + ">" + CSO.GetID() + " " + t_name[1])
         t_RefSO = CSO.ReferencedObject()
         if t_RefSO[0] == 1:
             RefSO = t_RefSO[1]
@@ -57,19 +60,20 @@ def DumpComponent(Study, SO, offset):
             while ofs <= offset:
                 a = a + "  "
                 ofs = ofs +1
-            print a + ">" + RefSO.GetID()
-        DumpComponent(Study, CSO, offset+2)
+            print(a + ">" + RefSO.GetID())
+        DumpComponent(CSO, offset+2)
 
     #--------------------------------------------------------------------------
 
-def DumpStudy(Study):
-    itcomp = Study.NewComponentIterator()
+def DumpStudy():
+    global myStudy
+    itcomp = myStudy.NewComponentIterator()
     while itcomp.More():
         SC = itcomp.Value()
         itcomp.Next()
         name = SC.ComponentDataType()
-        print "-> ComponentDataType is " + name
-        DumpComponent(Study, SC, 1)
+        print("-> ComponentDataType is " + name)
+        DumpComponent(SC, 1)
         
 
     #--------------------------------------------------------------------------
@@ -86,16 +90,10 @@ sg = SALOMEGUI_Swig()
 #create an naming service instance
 naming_service = SALOME_NamingServicePy_i(orb)
 
-# get active study name and id
-myStudyName = sg.getActiveStudyName()
-print myStudyName
-
-myStudyId = sg.getActiveStudyId()
-print myStudyId
-
-# get Study Manager reference
-obj = naming_service.Resolve('myStudyManager')
-myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+# get active study name
+myStudyName = sg.getStudyName()
+print(myStudyName)
 
-# get active study
-myStudy = myStudyManager.GetStudyByName(myStudyName)
+# get Study reference
+obj = naming_service.Resolve('/Study')
+myStudy = obj._narrow(SALOMEDS.Study)