From e703661cae11f69536cdf7308fb2021c0a9d5b6b Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Thu, 10 Mar 2011 08:59:52 +0000 Subject: [PATCH] [LMS-1979] minor: removed dead code SVN: 20280 --- .../cisd/common/evaluator/Evaluator.java | 40 +++---------------- .../cisd/common/evaluator/EvaluatorTest.java | 15 ------- 2 files changed, 6 insertions(+), 49 deletions(-) diff --git a/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java b/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java index f64b818486c..5760081414e 100644 --- a/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java +++ b/common/source/java/ch/systemsx/cisd/common/evaluator/Evaluator.java @@ -105,7 +105,7 @@ public final class Evaluator } this.interpreter = new PythonInterpreter(); // Security: do not allow file access. - + try { interpreter.exec("def open():\n pass"); @@ -133,11 +133,11 @@ public final class Evaluator PyObject pyObject = interpreter.get(functionName); return pyObject instanceof PyFunction; } - + /** - * Evaluates specified function with specified arguments. The arguments are turned into - * Python Strings if they are Java {@link String} objects. The return value of the function - * is returned as a Java object or <code>null</code>. + * Evaluates specified function with specified arguments. The arguments are turned into Python + * Strings if they are Java {@link String} objects. The return value of the function is returned + * as a Java object or <code>null</code>. * * @throws EvaluatorException if evaluation fails. */ @@ -166,7 +166,7 @@ public final class Evaluator } catch (PyException ex) { StringBuilder builder = new StringBuilder(); - for (Object argument : args) + for (Object argument : args) { if (builder.length() > 0) { @@ -203,34 +203,6 @@ public final class Evaluator } } - /** - * @throws EvaluatorException if compilation of given expression fails - */ - public static void checkExpressionCompilation(String expression) throws EvaluatorException - { - new PythonInterpreter(); - doCompile(expression); - } - - /** - * @throws EvaluatorException if compilation of given script fails - */ - public static void checkScriptCompilation(String script) throws EvaluatorException - { - try - { - PythonInterpreter pi = new PythonInterpreter(); - // Security: do not allow file access. - pi.exec("def open():\n pass"); - pi.exec(script); - } catch (PyException ex) - { - final String msg = - "Script compilation failed with message:\n\n" + extractExceptionMessage(ex); - throw new EvaluatorException(msg); - } - } - /** * Sets the variable <var>name</var> to <var>value</var> in the evaluator's name space. */ diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java index e22546dcd1e..0427ac7007b 100644 --- a/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java +++ b/common/sourceTest/java/ch/systemsx/cisd/common/evaluator/EvaluatorTest.java @@ -338,19 +338,4 @@ public class EvaluatorTest extends AssertJUnit } } - @Test - public void testCheckScriptCompilation() - { - Evaluator.checkScriptCompilation("1+1"); - try - { - Evaluator.checkScriptCompilation("1+"); - fail("EvaluatorException expected"); - } catch (EvaluatorException ex) - { - assertEquals("Script compilation failed with message:\n\n" - + "SyntaxError: ('invalid syntax', ('<string>', 1, 3, '1+'))", ex.getMessage()); - } - } - } -- GitLab