πŸ’Ύ IO

Contents

πŸ’Ύ IO#

Structured binary I/O.

Base#

Structured binary I/O primitives.

class StructIO(stream, order=None, errors=None, location=None)[source]#

Bases: Generic

Seekable binary stream wrapper for structured I/O.

mode: ClassVar[str]#

Binary mode used when opening a path.

order: ByteOrder = '<'#

Default byte order.

errors: str = 'replace'#

UTF-8 error handling mode.

property stream: IO[bytes]#
property location: str#
property closed: bool#
seek(position, whence=0)[source]#
Return type:

int

tell()[source]#
Return type:

int

size()[source]#
Return type:

int

seekable()[source]#
Return type:

bool

close()[source]#
Return type:

None

class StructReader(stream, order=None, errors=None, location=None)[source]#

Bases: StructIO[IOStream]

Structured binary reader.

mode: ClassVar[str] = 'rb'#

Binary mode used when opening a path.

read(size=-1)[source]#
Return type:

bytes

skip(size)[source]#
Return type:

int

eof()[source]#
Return type:

bool

readable()[source]#
Return type:

bool

read_exact(size)[source]#
Return type:

bytes

unpack(fmt, order=None)[source]#

Read and unpack structured values.

Return type:

tuple[Any, ...]

value(fmt, order=None)[source]#

Read one structured value.

Return type:

Any

array(dtype, count, order=None)[source]#

Read a NumPy array.

Return type:

GenericAlias[Any]

string(prefix=StructFormat.U16, order=None, limit=SafetyLimit.STRING)[source]#

Read a length-prefixed UTF-8 string.

Return type:

str

prefixed(prefix=StructFormat.U16, order=None, limit=None)[source]#

Read length-prefixed bytes.

Return type:

bytes

count(fmt, limit)[source]#

Read and validate a bounded count.

Return type:

int

check(value, limit)[source]#

Validate a decoded count.

Return type:

int

class StructWriter(stream, order=None, errors=None, location=None)[source]#

Bases: StructIO[OutputStream]

Structured binary writer.

mode: ClassVar[str] = 'wb+'#

Binary mode used when opening a path.

write(data)[source]#
Return type:

int

writable()[source]#
Return type:

bool

flush()[source]#
Return type:

None

to_bytes()[source]#

Return all bytes written to the stream.

Return type:

bytes

pack(fmt, *values, order=None)[source]#

Pack structured values.

Return type:

bytes

value(fmt, *values, order=None)[source]#

Write structured values.

Return type:

None

null(size=4)[source]#

Write null bytes.

Return type:

None

string(string)[source]#

Write a UTF-8 string.

Return type:

None

type IOStream#

SourceLike | IOBase | bytes

type OutputStream#

SourceLike | IOBase

Fbx#

Structured I/O extensions for FBX.

class FbxWriter(stream, order=None, errors=None, location=None)[source]#

Bases: StructWriter

header(end, properties, length, name=None)[source]#
Return type:

None

matrix(value)[source]#
Return type:

TypeAliasType

property(value)[source]#
Return type:

None

leaf(name, properties, root=False)[source]#
Return type:

None

animation_curve(curve, times, values, attributes, references, version)[source]#
Return type:

None

curve_data(times, attributes, references)[source]#
Return type:

tuple[bytes, bytes, bytes]

polygon_indices(polygons)[source]#
Return type:

TypeAliasType

Models#

Structured I/O extensions for models.

class ModelReader(stream, order=None, errors=None, location=None)[source]#

Bases: StructReader

vertex(fmt, factor, units, count, scale=1.0)[source]#
Return type:

ndarray

normals(count)[source]#
Return type:

TypeAliasType

tangents(count)[source]#
Return type:

TypeAliasType

blend_shapes(count, vertices, blend_vertex_map)[source]#
Return type:

TypeAliasType

polygons(count, quads=False)[source]#
Return type:

TypeAliasType

bone()[source]#
Return type:

TypeAliasType

clip(times_count, bones_count, channels_count, position_scale)[source]#
Return type:

tuple[ndarray, ndarray, ndarray]

Return type:

TypeAliasType

Return type:

TypeAliasType

Nbt#

Structured I/O extensions for NBT.

class Tag(*values)[source]#

Bases: IntEnum

END = 0#
BYTE = 1#
SHORT = 2#
INT = 3#
LONG = 4#
FLOAT = 5#
DOUBLE = 6#
BYTE_ARRAY = 7#
STRING = 8#
LIST = 9#
COMPOUND = 10#
INT_ARRAY = 11#
LONG_ARRAY = 12#
header(name=b'')[source]#

Encode a named NBT tag header.

Return type:

bytes

class NbtReader(stream, order=None, errors=None, location=None)[source]#

Bases: StructReader

order: ByteOrder = '>'#

Default byte order.

document()[source]#

Read one NBT document.

Return type:

TypeAliasType

tag()[source]#

Read one NBT tag type.

Return type:

Tag

parse(tag)[source]#

Read the payload of a known NBT tag.

Return type:

TypeAliasType

class NbtWriter(stream, order=None, errors=None, location=None)[source]#

Bases: StructWriter

Write NBT data to a binary stream.

order: ByteOrder = '>'#

Default byte order.

tag(tag, name=b'')[source]#

Write a named NBT tag header.

Return type:

None

list(tag, length)[source]#

Write an NBT list element type and length.

Return type:

None

end()[source]#

Write an NBT compound terminator.

Return type:

None

Ol#

Structured I/O extensions for OL.

class OlReader(stream, order=None, errors=None, location=None)[source]#

Bases: StructReader

sizes(mipmap_count)[source]#
Return type:

list[int]

cubemap_sizes(mipmap_count)[source]#
Return type:

list[list[int]]

format()[source]#
Return type:

bytes