]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
INT PAL 53005: Operators if/else, for, try/except, etc do not work in embedded Python...
authormpa <mpa@opencascade.com>
Tue, 8 Dec 2015 12:34:09 +0000 (15:34 +0300)
committermpa <mpa@opencascade.com>
Tue, 8 Dec 2015 12:34:09 +0000 (15:34 +0300)
src/PyInterp/PyInterp_Interp.cxx

index 5da3c537f5fa797b73880988fdfe81f8da4bda32..f77fb1a8b50807e7bc7a08a87596824941fe66d7 100644 (file)
@@ -38,6 +38,8 @@
 #include <sstream>
 #include <algorithm>
 
+#include <QRegExp>
+
 #define TOP_HISTORY_PY   "--- top of history ---"
 #define BEGIN_HISTORY_PY "--- begin of history ---"
 
@@ -450,13 +452,10 @@ static int compile_command(const char *command, PyObject * global_ctxt, PyObject
   std::string singleCommand = command;
   std::string commandArgs = "";
 
-  if (singleCommand.size() > 0 && singleCommand.at(singleCommand.size()-1) == '\n')
-    singleCommand.erase(singleCommand.size()-1);
-  std::size_t pos = singleCommand.find("args:");
-  if (pos != std::string::npos) {
-    commandArgs = singleCommand.substr(pos+5);
-    commandArgs = commandArgs.substr(0, commandArgs.length()-2);
-    singleCommand = singleCommand.substr(0, pos-1)+"\")";
+  QRegExp rx("execfile\\s*\\(.*(args:.*)\"\\s*\\)");
+  if (rx.indexIn(command) != -1) {
+    commandArgs = rx.cap(1).remove(0,5).toStdString(); // arguments of command
+    singleCommand = rx.cap().remove(rx.cap(1)).remove(" ").toStdString(); // command for execution without arguments
   }
 
   if (commandArgs.empty()) {