From db7c51ff3d57d1d699799257ba0699f7d6a837e7 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 11 Apr 2022 11:43:02 +0300 Subject: [PATCH] [bos #29612] EDF 25161 - dump with comments --- src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 14 +++++++- .../Test/TestQuotesInComment.py | 36 +++++++++++++++++++ src/ParametersPlugin/tests.set | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/ParametersPlugin/Test/TestQuotesInComment.py diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 09900d6b8..5f9bf3d8d 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -1275,13 +1275,25 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( const std::shared_ptr& theAttrStr) { - // escaping the quote sign in the string under dumping + // escaping the quote signs in the string under dumping std::string aStr = theAttrStr->value(); + /* size_t aPos = aStr.find("\""); while (aPos != std::string::npos) { aStr.insert(aPos, "\\"); aPos = aStr.find("\"", aPos + 2); } + aPos = aStr.find("\'"); + while (aPos != std::string::npos) { + aStr.insert(aPos, "\\"); + aPos = aStr.find("\'", aPos + 2); + } + */ + size_t aPos = aStr.find_first_of("\"\'"); + while (aPos != std::string::npos) { + aStr.insert(aPos, "\\"); + aPos = aStr.find_first_of("\"\'", aPos + 2); + } *myDumpStorage << "'" << aStr << "'"; return *this; } diff --git a/src/ParametersPlugin/Test/TestQuotesInComment.py b/src/ParametersPlugin/Test/TestQuotesInComment.py new file mode 100644 index 000000000..9142a7a32 --- /dev/null +++ b/src/ParametersPlugin/Test/TestQuotesInComment.py @@ -0,0 +1,36 @@ +# Copyright (C) 2014-2021 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 +# 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 +# + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +model.addParameter(Part_1_doc, "a", '10', 'longueur de l\'aile') +model.addParameter(Part_1_doc, "b", '12', 'trou à l\"origine') +model.addParameter(Part_1_doc, "c", '14', 'l\'opposé de l\"origine') + +Box_1 = model.addBox(Part_1_doc, "a", "b", "c") + +model.end() + +assert(len(Box_1.feature().error()) == 0) +assert(model.checkPythonDump()) diff --git a/src/ParametersPlugin/tests.set b/src/ParametersPlugin/tests.set index 668f4668f..6eaeaf6c1 100644 --- a/src/ParametersPlugin/tests.set +++ b/src/ParametersPlugin/tests.set @@ -30,4 +30,5 @@ SET(TEST_NAMES Test19036.py TestImportParameters.py TestImportInvalidParameters.py + TestQuotesInComment.py ) -- 2.30.2