Salome HOME
Copyright update 2022
[modules/med.git] / src / MEDCalculator / Swig / SPythonInterpreter.cxx
index 2b24e5d8acc1e01b18148d4c66a553fc5462eed0..5a0b5b6dfcf997bb4f1dfcf01ec2c036d7c5c942 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2022  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
@@ -25,7 +25,7 @@
 #include <sstream>
 #include <algorithm>
 
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
 
 const char *SPythonInterpreter::INDENT_TOKEN[]={"def","class","for","if","while","try","except"};
 
@@ -193,12 +193,14 @@ bool SPythonInterpreter::isSPythonExpression(const std::string& s)
     return false;
   if(w.find("del ")!=std::string::npos)
     return false;
-  const char PRINT[]="print ";
+  const char PRINT[]="print(";
+  const char ENDPRINT[]=")";
   bool isPrint=w.find(PRINT)!=std::string::npos;
+  isPrint &= w.find(ENDPRINT)!=std::string::npos;
   if(isPrint)
     {
       std::size_t p=w.find(PRINT);
-      w=w.substr(p+sizeof(PRINT)-1);
+      w=w.substr(p+sizeof(PRINT)-sizeof(ENDPRINT)-1);
     }
   std::string result;
   if(!isSPythonExpressionLev1(w,result))