X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FKERNEL_PY%2Fsalome_notebook.py;h=2721cf0a40971fbc123ca47c04e847c6dbd09b67;hb=513b8629ac55467ab7f604cd1733b542f7e9a40a;hp=c8823d4b762b1400c8c3e3862ed4aadb43517942;hpb=0fac7040be417aab7228a4e23904b4cf22a8dda4;p=modules%2Fkernel.git diff --git a/src/KERNEL_PY/salome_notebook.py b/src/KERNEL_PY/salome_notebook.py index c8823d4b7..2721cf0a4 100644 --- a/src/KERNEL_PY/salome_notebook.py +++ b/src/KERNEL_PY/salome_notebook.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ class PseudoStudyForNoteBook(object): pass def GetVariableNames(self): - return self.kwargs.keys() + return list(self.kwargs.keys()) def IsVariable(self, variableName): return variableName in self.kwargs @@ -69,24 +69,27 @@ class PseudoStudyForNoteBook(object): class NoteBook: - def __init__(self, Study): - self.myStudy = Study + def __init__(self, theIsEnablePublish = True): + if theIsEnablePublish: + self.myStudy = salome.myStudy + else: + self.myStudy = PseudoStudyForNoteBook() def set(self, variableName, variable): """ Create (or modify) variable with name "variableName" and value equal "theValue". """ - if type(variable) == float: + if isinstance(variable, float): self.myStudy.SetReal(variableName, variable) - elif type(variable) == int: + elif isinstance(variable, int): self.myStudy.SetInteger(variableName, variable) - elif type(variable) == bool: + elif isinstance(variable, bool): self.myStudy.SetBoolean(variableName, variable) - elif type(variable) == str: + elif isinstance(variable, str): self.myStudy.SetString(variableName, variable) def get(self, variableName): @@ -124,7 +127,7 @@ class NoteBook: pass try: aResult = eval(aResult) - except Exception, e: + except Exception as e: msg = str(e) msg += "\n" msg += "A problem occurs while parsing " @@ -171,9 +174,8 @@ class NoteBook: pass def checkThisNoteBook(**kwargs): - study = PseudoStudyForNoteBook(**kwargs) - note_book = NoteBook(study) + note_book = NoteBook( False ) note_book.check() return -notebook = NoteBook(salome.myStudy) +notebook = NoteBook()