API Reference

nbtparse Package

Named Binary Tag manipulation tools.

This package contains various utilities for manipulating NBT-formatted data.

NBT is used by Minecraft to store a variety of data and metadata.

  • syntax contains modules relating to low-level NBT syntax.
  • semantics contains modules relating to intermediate-level constructs.
  • minecraft contains modules directly relating to Minecraft’s file and data structures.

NBTParse logs to loggers with the same names as its modules and packages. You can therefore control logging for the entire package via the NBTParse root logger:

nbtparse_root_logger = logging.getLogger('nbtparse')

By default (as of Python 3.4), the logging package will emit warnings and more severe logged events on sys.stderr, while dropping less severe events. Consult the logging documentation if you wish to override this behavior.

nbtparse.__version__ = '0.8.0.dev0'

The version number string for NBTParse, or None if version information is not available. The numbering scheme is strictly compatible with PEP 440 and loosely compatible with Semantic Versioning, allowing some deviations from the latter to satisfy the former.

Strictly speaking, NBTParse does not comply with SemVer at all, and the above link is at best misleading. This results from SemVer’s heavy use of the MUST keyword.

Note

As a matter of policy, this value ends in .dev0 on the trunk. Since the version number is not changed from one commit to the next, trunk snapshots may appear to have the same version number even if they are materially different. Such snapshots are not official releases. New snapshots downloaded from https://ci.nbtparse.org/ will use the build number here instead.

exceptions Module

exception nbtparse.exceptions.ClassWarning[source]

Bases: UserWarning

Warning issued when a class definition is dubious.

exception nbtparse.exceptions.ConcurrentError[source]

Bases: Exception

Exception raised when concurrent operations conflict.

NBTParse is generally not thread-safe. These exceptions are usually only raised in response to process-level concurrency (e.g. while interacting with the filesystem). Thread safety violations may cause this exception to be raised, but you should not depend on this behavior.

exception nbtparse.exceptions.DuplicateIDError[source]

Bases: Exception

Exception raised when an entity ID is registered more than once.

exception nbtparse.exceptions.IncompleteSequenceError[source]

Bases: nbtparse.exceptions.MalformedNBTError

Raised if a sequence is incomplete (i.e. we hit EOF too early).

exception nbtparse.exceptions.MalformedNBTError[source]

Bases: Exception

Base class of all exceptions caused by malformed or invalid NBT.

NBT does not provide any easy method to recover from this sort of error.

The source file’s offset pointer is not reset, because it might not be possible to do so. If you want to seek back to the beginning, do so manually.

exception nbtparse.exceptions.NoSuchTagTypeError[source]

Bases: nbtparse.exceptions.MalformedNBTError

Raised if an unrecognized tag type is used.

exception nbtparse.exceptions.ParserError[source]

Bases: Exception

Exception raised by minecraft.ids.read_config().

Raised if the config file is ill-formed.

exception nbtparse.exceptions.SliceWarning[source]

Bases: UserWarning

Warning issued when using dubious slicing syntax.

exception nbtparse.exceptions.UnclosedWarning[source]

Bases: UserWarning

Warning issued when an object is not closed properly.

This is usually issued by a finalizer, so it’s probably a bad idea to convert these warnings into exceptions. Exceptions raised in a finalizer will just be turned back into warnings anyway.

exception nbtparse.exceptions.ValueWarning[source]

Bases: UserWarning

Warning issued when passing dubious values.