Salome HOME
update modules FIELDS
[modules/med.git] / src / MEDCalc / tui / medconsole.py
index c61942d4b46d7a5e2fd38ae38504bc29361fe047..071b4bf527acf3d7b3a6180ba42b7c61f470964a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2015  CEA/DEN, EDF R&D
+# Copyright (C) 2012-2019  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -22,13 +22,13 @@ import medcalc
 dataManager = medcalc.medcorba.factory.getDataManager()
 
 # IMPORTANT NOTE:
-# the pyConsoleGlobals variable should hold the globals() dictionnary of
+# the pyConsoleGlobals variable should hold the globals() dictionary of
 # the python console context
 pyConsoleGlobals = None
 
 #-----
 # This function is to be called from the working python console to
-# specify the globals() dictionnary (used in fieldtools for stat analysis)
+# specify the globals() dictionary (used in fieldtools for stat analysis)
 #
 # >>> medcalc.setConsoleGlobals(globals())
 #
@@ -45,34 +45,34 @@ def saveWorkspace(filename):
   """
   try:
     dataManager.savePersistentFields(filename)
-  except SALOME.SALOME_Exception, ex:
+  except SALOME.SALOME_Exception as ex:
     medcalc.err(ex.details.text)
 #
 
 # Clean workspace
-from medevents import notifyGui_cleanWorkspace
+from .medevents import notifyGui_cleanWorkspace
 def cleanWorkspace():
   dvars = pyConsoleGlobals
   if dvars is None:
     return
   all_keys = []
-  for varkey, var in dvars.items():
+  for varkey, var in list(dvars.items()):
     if isinstance(var, medcalc.FieldProxy):
       all_keys.append("%s"%varkey)
   if len(all_keys) > 0:
-    exec "del "+",".join(all_keys) in pyConsoleGlobals
+    exec("del "+",".join(all_keys), pyConsoleGlobals)
   notifyGui_cleanWorkspace()
 #
 
 # Remove variable from console
-from medevents import notifyGui_removeFromWorkspace
+from .medevents import notifyGui_removeFromWorkspace
 def removeFromWorkspace(fieldProxy):
   dvars = pyConsoleGlobals
   if dvars is None:
     return
-  for varkey, var in dvars.items():
+  for varkey, var in list(dvars.items()):
     if isinstance(var, medcalc.FieldProxy) and var.id == fieldProxy.id:
-      exec("del %s"%varkey) in pyConsoleGlobals
+      exec(("del %s"%varkey), pyConsoleGlobals)
   notifyGui_removeFromWorkspace(fieldProxy.id)
 #
 
@@ -90,7 +90,7 @@ def getEnvironment(local=True, remote=False):
       medcalc.inf("Type this command \"import medcalc; medcalc.setConsoleGlobals(globals())")
     if remote is True:
       status="========= Fields used in the current context ===\n"
-    for varkey in dvars.keys():
+    for varkey in list(dvars.keys()):
       var = dvars[varkey]
       if isinstance(var, medcalc.FieldProxy):
         status+="%s \t(id=%s, name=%s)\n"%(varkey,var.id,var.fieldname)
@@ -116,7 +116,7 @@ def getEnvironment(local=True, remote=False):
 #
 
 # For simpler typing, one can create a python command for status
-# (avoid to type "print getEnvironment()")
+# (avoid to type "print(getEnvironment())")
 class ListFields(object):
   """
   A stat object displays the status of the med operating context, i.e. the
@@ -140,7 +140,7 @@ la = ListFields(all=True)
 
 #
 # Add variable to workspace
-from medevents import notifyGui_putInWorkspace
+from .medevents import notifyGui_putInWorkspace
 def putInWorkspace(fieldProxy):
   """
   This function puts a reference to this field in the GUI data