V1PlateWriter

class wwt_data_formats.plate.V1PlateWriter(stream: BinaryIO, levels: int)[source]

Bases: object

Writer for the “V1” WWT plate file format.

Parameters:
streamwriteable, seekable, bytes-based file-like object

The underlying data destination. This object becomes responsible for closing the stream.

levelsint

The number of tile levels to allocate for this plate file. Must be nonnegative.

Notes

This file format assumes that tile data will be densely populated up to the specified number of levels (although missing entries are allowed). The maximum final file size is 4 GiB.

This object is usable as a context manager, and should be explicitly closed.

Unlike most of the other WWT data formats implemented in this package, plate files are stored in a simple binary structure, not XML.

Methods Summary

append_bytes(level, x, y, data)

Append a tile to the plate file, getting data from a bytes buffer.

append_stream(level, x, y, stream)

Append a tile to the plate file, getting data from a file-like object.

close()

Close the writer.

Methods Documentation

append_bytes(level: int, x: int, y: int, data: bytes)[source]

Append a tile to the plate file, getting data from a bytes buffer.

Parameters:
levelint

The level of the tile to write

xint

The X position of the tile to write

yint

The Y position of the tile to write

databytes

The tile data.

Returns:
lengthint

The number of bytes written to the plate file, which is the length of data.

append_stream(level: int, x: int, y: int, stream: BinaryIO)[source]

Append a tile to the plate file, getting data from a file-like object.

Parameters:
levelint

The level of the tile to write

xint

The X position of the tile to write

yint

The Y position of the tile to write

streamreadable, bytes-based file-like object

The source of tile data.

Returns:
lengthint

The number of bytes read from stream and written to the plate file.

Notes

This method reads stream until end of file, but does not take responsibility for closing it.

close()[source]

Close the writer.

This writes out the index of tile data and closes the underlying stream, making this object unusable for future I/O.