spockbot.mcp.nbt module

Handle the NBT (Named Binary Tag) data format

exception spockbot.mcp.nbt.MalformedFileError

Bases: Exception

Exception raised on parse error.

class spockbot.mcp.nbt.Tag(value=None, name=None)

Bases: object

Tag, a variable with an intrinsic name.

__repr__()

Return a string (ascii formated for Python 2, unicode for Python 3) describing the class, name and id for debugging purposes.

__str__()

Return a string (ascii formated for Python 2, unicode for Python 3) with the result in human readable format. Unlike valuestr(), the result is recursive for iterators till at least one level deep.

__unicode__()

Return a unicode string with the result in human readable format. Unlike valuestr(), the result is recursive for iterators till at least one level deep.

id = None
pretty_tree(indent=0)

Return formated Unicode string of self, where iterable items are recursively listed in detail.

tag_info()

Return Unicode string with class, name and unnested value.

valuestr()

Return Unicode string of unnested value. For iterators, this returns a summary.

class spockbot.mcp.nbt.TagByte(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt._TagNumeric

Represent a single tag storing 1 byte.

fmt = <Struct object>
id = 1
class spockbot.mcp.nbt.TagByteArray(name=None, buffer=None)

Bases: spockbot.mcp.nbt.Tag, collections.abc.MutableSequence

TagByteArray, comparable to a collections.UserList with an intrinsic name whose values must be bytes

id = 7
insert(key, value)
valuestr()
class spockbot.mcp.nbt.TagCompound(buffer=None)

Bases: spockbot.mcp.nbt.Tag, collections.abc.MutableMapping

TagCompound, comparable to a collections.OrderedDict with an intrinsic name

id = 10
iteritems()
keys()
pretty_tree(indent=0)
valuestr()
class spockbot.mcp.nbt.TagDouble(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt._TagNumeric

Represent a single tag storing 1 IEEE-754 double precision floating point number.

fmt = <Struct object>
id = 6
class spockbot.mcp.nbt.TagFloat(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt._TagNumeric

Represent a single tag storing 1 IEEE-754 floating point number.

fmt = <Struct object>
id = 5
class spockbot.mcp.nbt.TagInt(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt._TagNumeric

Represent a single tag storing 1 int.

fmt = <Struct object>
id = 3
class spockbot.mcp.nbt.TagIntArray(name=None, buffer=None)

Bases: spockbot.mcp.nbt.Tag, collections.abc.MutableSequence

TagIntArray, comparable to a collections.UserList with an intrinsic name whose values must be integers

id = 11
insert(key, value)
update_fmt(length)

Adjust struct format description to length given

valuestr()
class spockbot.mcp.nbt.TagList(type=None, value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt.Tag, collections.abc.MutableSequence

TagList, comparable to a collections.UserList with an intrinsic name

id = 9
insert(key, value)
pretty_tree(indent=0)
valuestr()
class spockbot.mcp.nbt.TagLong(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt._TagNumeric

Represent a single tag storing 1 long.

fmt = <Struct object>
id = 4
class spockbot.mcp.nbt.TagShort(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt._TagNumeric

Represent a single tag storing 1 short.

fmt = <Struct object>
id = 2
class spockbot.mcp.nbt.TagString(value=None, name=None, buffer=None)

Bases: spockbot.mcp.nbt.Tag, collections.abc.Sequence

TagString, comparable to a collections.UserString with an intrinsic name

id = 8