I would like to rewrite CCSDS files from KVN onto XML format.
In TdmParserTest (Java code), I saw that once I have a Tdm object (named “original”), I could simply do that:
final CharArrayWriter caw = new CharArrayWriter();
final Generator generator = new KvnGenerator(caw, TdmWriter.KVN_PADDING_WIDTH, "dummy", 60);
new WriterBuilder().withRangeUnitsConverter(null).buildTdmWriter().writeMessage(generator, original);
However CharArrayWriter is a Java object, not an Orekit one. Is there a way to create it from Python anyway?
thanks for the link. This seems to do the trick for the pure Java object indeed. However I’m now getting an error saying that a TdmWriter does not have an attribute called writeMessage, but it’s a method so I don’t understand. Here is the code:
It seems to be an issue related to Python. Indeed, the writeMessage(...) method is in the MessageWriter interface, implemented by the TdmWriter. However, as the method is by default in the interface and not overridden by the TdmWriter, maybe the problem is due to the cast. Did you tried this:
I changed the cast to TdmWriter with MessageWriter and I don’t get any errors any more.
However, I have no clue where the file has been written…
It is not clear to me at all where the MessageWriter operates.
Thank you @pascal.parraud for the clarifications!
By rereading the other discussion cited by Bryan, I realized I was actually missing the last part in Python post-processing the StringBuilder!