Commit 969a33d8 authored by Jerome Hugues's avatar Jerome Hugues

* Use runOcarinaFunction instead of copy/pasting same piece of

          code

          For issue #71
parent 333b9aac
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -2723,56 +2723,12 @@ package body Parser is
Output.Write_Str (" (N):");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("info = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("error = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("raisedError = []");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("res = ''");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("with std_redirector(info,error):");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("try:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("res = libocarina_python.");
Output.Write_Str ("return runOcarinaFunction (libocarina_python.");
Output.Write_Str (Ada.Directories.Base_Name
(Namet.Get_Name_String (Output_Name)));
Output.Write_Str ("_");
Output.Write_Str (A);
Output.Write_Str (" (");
Output.Write_Eol;
W_Indentation (4);
Output.Write_Str ("N)");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("except:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("raisedError.append(getErrorMessage())");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("stderrMsg = sortStderrMessages(error");
Output.Write_Str (".getvalue().decode('utf-8'))");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("if stderrMsg[1]!=[]:");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError.append(stderrMsg[1])");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("return [ res , info.getvalue().");
Output.Write_Str ("decode('utf-8'), stderrMsg[0] , ");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError ]");
Output.Write_Str (", N)");
Output.Write_Eol;
Output.Write_Eol;
......@@ -2784,56 +2740,12 @@ package body Parser is
Output.Write_Str (" (N, V):");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("info = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("error = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("raisedError = []");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("res = ''");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("with std_redirector(info,error):");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("try:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("libocarina_python.");
Output.Write_Str ("return runOcarinaFunction (libocarina_python.");
Output.Write_Str (Ada.Directories.Base_Name
(Namet.Get_Name_String (Output_Name)));
Output.Write_Str ("_");
Output.Write_Str (WS (A));
Output.Write_Str (" (");
Output.Write_Eol;
W_Indentation (4);
Output.Write_Str ("N, V)");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("except:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("raisedError.append(getErrorMessage())");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("stderrMsg = sortStderrMessages(error.");
Output.Write_Str ("getvalue().decode('utf-8'))");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("if stderrMsg[1]!=[]:");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError.append(stderrMsg[1])");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("return [ res , info.getvalue().");
Output.Write_Str ("decode('utf-8'), stderrMsg[0] , ");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError ]");
Output.Write_Str (", N, V)");
Output.Write_Eol;
Output.Write_Eol;
......@@ -2859,56 +2771,12 @@ package body Parser is
Output.Write_Str (" (N):");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("info = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("error = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("raisedError = []");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("res = ''");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("with std_redirector(info,error):");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("try:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("res = libocarina_python.");
Output.Write_Str ("return runOcarinaFunction (libocarina_python.");
Output.Write_Str (Ada.Directories.Base_Name
(Namet.Get_Name_String (Output_Name)) & "_python");
Output.Write_Str ("_");
Output.Write_Str (GNS (Identifier (A)));
Output.Write_Str (" (");
Output.Write_Eol;
W_Indentation (4);
Output.Write_Str ("N)");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("except:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("raisedError.append(getErrorMessage())");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("stderrMsg = sortStderrMessages(error.");
Output.Write_Str ("getvalue().decode('utf-8'))");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("if stderrMsg[1]!=[]:");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError.append(stderrMsg[1])");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("return [ res , info.getvalue().");
Output.Write_Str ("decode('utf-8'), stderrMsg[0] , ");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError ]");
Output.Write_Str (", N)");
Output.Write_Eol;
Output.Write_Eol;
......@@ -2920,56 +2788,12 @@ package body Parser is
Output.Write_Str (" (N, V):");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("info = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("error = io.BytesIO()");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("raisedError = []");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("res = ''");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("with std_redirector(info,error):");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("try:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("libocarina_python.");
Output.Write_Str ("return runOcarinaFunction (libocarina_python.");
Output.Write_Str (Ada.Directories.Base_Name
(Namet.Get_Name_String (Output_Name)) & "_python");
Output.Write_Str ("_");
Output.Write_Str (WS (GNS (Identifier (A))));
Output.Write_Str (" (");
Output.Write_Eol;
W_Indentation (4);
Output.Write_Str ("N, V)");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("except:");
Output.Write_Eol;
W_Indentation (3);
Output.Write_Str ("raisedError.append(getErrorMessage())");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("stderrMsg = sortStderrMessages(error.");
Output.Write_Str ("getvalue().decode('utf-8'))");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("if stderrMsg[1]!=[]:");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError.append(stderrMsg[1])");
Output.Write_Eol;
W_Indentation (1);
Output.Write_Str ("return [ res , info.getvalue().");
Output.Write_Str ("decode('utf-8'), stderrMsg[0] , ");
Output.Write_Eol;
W_Indentation (2);
Output.Write_Str ("raisedError ]");
Output.Write_Str (", N, V)");
Output.Write_Eol;
Output.Write_Eol;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment