lxml supports paths already, no modification is necessary there.
However, the lxml.etree.ElementTree.write() function requires
BinaryIO, i.e. files opened with the 'b' mode. While it would be
possible to access the underlying binary buffer of files opened in text
mode via open(), this isn't possible for io.StringIO(), as it
doesn't have the buffer property. Thus, even if we could support files
opened via open() in text mode, we couldn't annotate the XML
serialization functions with TextIO, as io.StringIO() remains
unsupported. Because of that, I decided to not support TextIO for the
XML serialization.
The builtin JSON module only supports file handles, with the
json.dump() method only supporting TextIO and json.load()
supporting TextIO and BinaryIO. Thus, the JSON adapter is modified
to open() given paths, while the JSON serialization is additionally
modified to wrap BinaryIO with io.TextIOWrapper.
lxml supports paths already, no modification is necessary there. However, the
lxml.etree.ElementTree.write()
function requiresBinaryIO
, i.e. files opened with the 'b' mode. While it would be possible to access the underlying binary buffer of files opened in text mode viaopen()
, this isn't possible forio.StringIO()
, as it doesn't have thebuffer
property. Thus, even if we could support files opened viaopen()
in text mode, we couldn't annotate the XML serialization functions withTextIO
, asio.StringIO()
remains unsupported. Because of that, I decided to not supportTextIO
for the XML serialization.The builtin JSON module only supports file handles, with the
json.dump()
method only supportingTextIO
andjson.load()
supportingTextIO
andBinaryIO
. Thus, the JSON adapter is modified toopen()
given paths, while the JSON serialization is additionally modified to wrapBinaryIO
withio.TextIOWrapper
.Fix https://github.com/eclipse-basyx/basyx-python-sdk/issues/42