]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Replace a fix by another fix ...
authoradam <adam>
Fri, 9 Oct 2009 09:33:41 +0000 (09:33 +0000)
committeradam <adam>
Fri, 9 Oct 2009 09:33:41 +0000 (09:33 +0000)
src/KERNEL_PY/salome_notebook.py

index 48404bff94672e908901d7147bc190164e54df4d..630163e8a0e0cc79b8a2990f77e888015dfda547 100644 (file)
@@ -110,14 +110,17 @@ class NoteBook:
                 aResult_orig = aResult
                 l = self.myStudy.GetVariableNames()
                 l.remove(variableName)
+                # --
+                # To avoid the smallest strings to be replaced first,
+                # the list is sorted by decreasing lengths
+                # --
+                l.sort(key=str.__len__)
+                l.reverse()
                 for name in l:
-                   val = self.get(name)
-                   import re
-                   while 1:
-                       m = re.search(r"\b(%s)\b"%name, aResult)
-                       if not m: break
-                       aResult = aResult[:m.start()] + "%s"%(val) + aResult[m.end():]
-                       pass
+                    if aResult.find(name) >= 0:
+                        val = self.get(name)
+                        aResult = aResult.replace(name, "%s"%(val))
+                        pass
                     pass
                 try:
                     aResult = eval(aResult)