+ getNetwork().getName().replaceAll("\\p{Blank}|\\p{Punct}", ((Character) scriptData.get("spaceDelim")).toString());
py.append(String.format("%1s.connect(", pythonNetworkName));
StringBuilder originNodeFullName = new StringBuilder();
Origin tempOrigin = myOrigin;
while(tempOrigin instanceof OriginWrapper)
{
originNodeFullName.append(tempOrigin.getNode().getName() + ".");
tempOrigin = ((OriginWrapper) tempOrigin).getWrappedOrigin();
}
StringBuilder terminationNodeFullName = new StringBuilder();
Termination tempTermination = myTermination;
while(tempTermination instanceof TerminationWrapper)
{
terminationNodeFullName.append(tempTermination.getNode().getName() + ".");
tempTermination = ((TerminationWrapper) tempTermination).getWrappedTermination();
}
DecodedTermination dTermination;
StringBuilder transformString = new StringBuilder();
transformString.append('[');
if(tempTermination instanceof DecodedTermination)
{
dTermination = (DecodedTermination) tempTermination;
transformString.append(getTransformScript(dTermination, "transform = ".length()));
terminationNodeFullName.append(tempTermination.getNode().getName());
}
else if(tempTermination instanceof EnsembleTermination &&
tempTermination.getNode() instanceof NetworkArrayImpl)
{
terminationNodeFullName.deleteCharAt(terminationNodeFullName.length()-1);
boolean first = true;
for(Node node : tempTermination.getNode().getChildren())
{
if(first)
{
first = false;
}else {
transformString.append(",\n" + new String(new char["transform = ".length() + 1]).replace("\0", " "));
}
// this relies on the decoded terminations in the child nodes having the
// same name as the ensemble termination that contains them
try{
dTermination = (DecodedTermination) node.getTermination(tempTermination.getName());
}catch(Exception e){
dTermination = null;
}
transformString.append(getTransformScript(dTermination, "transform = ".length() + 1));
}
}
else
{
throw new ScriptGenException("Trying to generate script of non decoded termination which is not supported.");
}
transformString.append("]\n");
// Now handle origin function if there is one
String functionName = "";
if(tempOrigin instanceof BasicOrigin && tempOrigin.getNode() instanceof FunctionInput)
{
originNodeFullName.append(tempOrigin.getNode().getName());
}
else
{
DecodedOrigin dOrigin;
if(tempOrigin instanceof DecodedOrigin)
{
dOrigin = (DecodedOrigin) tempOrigin;
originNodeFullName.append(tempOrigin.getNode().getName());
}
else if(tempOrigin instanceof NetworkArrayImpl.ArrayOrigin &&
tempOrigin.getNode() instanceof NetworkArrayImpl)
{
originNodeFullName.deleteCharAt(originNodeFullName.length()-1);
Node node = tempOrigin.getNode().getChildren()[0];
try{
dOrigin = (DecodedOrigin) node.getOrigin(tempOrigin.getName());
}catch(StructuralException e){
dOrigin = null;
}
}
else