from net.sourceforge.plantuml import SourceStringReader
from java.io import ByteArrayOutputStream
from net.sourceforge.plantuml import FileFormatOption,FileFormat
from java.lang import String
from java.nio.charset import Charset
source = "@startuml\nscale 600*400\n  Alex -> Roman : hello\n  Tania -> Steve : connect\n  @enduml\n";
reader=SourceStringReader(source)

os=ByteArrayOutputStream();
# Write the first image to "os"
desc = reader.generateImage(os, FileFormatOption(FileFormat.EPS));
os.close()
svg=String(os.toByteArray(), Charset.forName("UTF-8"))

xf="diagram.eps" # write to file 
f=open(xf,"w")
f.write(svg.toString())
f.close()
print "Making:",xf

