From: adam Date: Fri, 9 Oct 2009 09:33:41 +0000 (+0000) Subject: Replace a fix by another fix ... X-Git-Tag: V5_1_3rc1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c5513d3a6575216f559136c56878d6ee7b5419fc;p=modules%2Fkernel.git Replace a fix by another fix ... --- diff --git a/src/KERNEL_PY/salome_notebook.py b/src/KERNEL_PY/salome_notebook.py index 48404bff9..630163e8a 100644 --- a/src/KERNEL_PY/salome_notebook.py +++ b/src/KERNEL_PY/salome_notebook.py @@ -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)