From 37d61a543c7ce93a716bf9621e787d6141ea2c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rgen=20Brandt?= Date: Mon, 4 Jan 2016 12:44:35 +0100 Subject: [PATCH] Python scripts work with and without indentation. --- .../de/huberlin/wbi/cuneiform/core/invoc/Invocation.java | 5 ++++- .../huberlin/wbi/cuneiform/core/invoc/PythonInvocation.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/Invocation.java b/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/Invocation.java index 972e7cd..281fc29 100644 --- a/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/Invocation.java +++ b/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/Invocation.java @@ -306,7 +306,7 @@ public String toScript() throws NotBoundException, NotDerivableException { // insert function body buf.append( comment( "insert function body" ) ); - buf.append( ticket.getBody() ).append( '\n' ); + buf.append( postProcess( ticket.getBody() ) ).append( '\n' ); // rename output files buf.append( comment( "rename output files" ) ); @@ -769,6 +769,9 @@ protected String getStageOutCollect() { return buf.toString(); } + @SuppressWarnings("static-method") + protected String postProcess( String body ) { return body; } + public static Invocation createInvocation( Ticket ticket ) { String label, libPath; diff --git a/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/PythonInvocation.java b/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/PythonInvocation.java index 81679d6..5538902 100644 --- a/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/PythonInvocation.java +++ b/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/invoc/PythonInvocation.java @@ -256,5 +256,10 @@ protected String varDef( String varname, String value ) { protected String getLibPath() { return callProcedure( "sys.path.append", quote( libPath ) ); } + + @Override + protected String postProcess( String body ) { + return body.replace( "\n", "\n " ); + } }