nbt
Python Parser/Writer for the NBT file format, and it's container the RegionFile.
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 30 committers (6.7%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.4%) to scientific vocabulary
Repository
Python Parser/Writer for the NBT file format, and it's container the RegionFile.
Basic Info
Statistics
- Stars: 368
- Watchers: 14
- Forks: 75
- Open Issues: 61
- Releases: 8
Metadata Files
README.md
The NBT library for Python
Forewords
This is mainly a Named Binary Tag parser & writer library.
From the initial specification by Markus Persson:
NBT (Named Binary Tag) is a tag based binary format designed to carry large
amounts of binary data with smaller amounts of additional data.
An NBT file consists of a single GZIPped Named Tag of type TAG_Compound.
Current specification is on the official Minecraft Wiki.
This library is very suited to inspect & edit the Minecraft data files. Provided examples demonstrate how to: - get player and world statistics, - list mobs, chest contents, biomes, - draw a simple world map, - etc.

Note: Examples are just here to help using and testing the library. Developing Minecraft tools is out of the scope of this project.
Status
The library supports all the currently known tag types (including the arrays of 'Integer' and 'Long'), and the examples work with the McRegion, pre-"flattened" and "flattened" Anvil formats.
Last update was tested on Minecraft version 1.13.2.
Dependencies
The library, the tests and the examples are only using the Python core library,
except curl for downloading some test reference data and PIL (Python
Imaging Library) for the map example.
Supported Python releases: 2.7, 3.4 to 3.7
Usage
Reading files
The easiest way to read an nbt file is to instantiate an NBTFile object e.g. ```
from nbt import nbt nbtfile = nbt.NBTFile("bigtest.nbt",'rb') nbtfile.name u'Level' nbtfile["nested compound test"].taginfo() TAGCompound("nested compound test"): 2 Entries for tag in nbtfile["nested compound test"]["ham"].tags: ... print(tag.taginfo()) ... TAGString("name"): Hampus TAG_Float("value"): 0.75 [tag.value for tag in nbtfile["listTest (long)"].value] [11, 12, 13, 14, 15] ```
Files can also be read from a fileobj (file-like object that contains a compressed stream) or a buffer (file-like object that contains an uncompressed stream of NBT Tags) which can be accomplished thusly: ```
from nbt.nbt import NBTFile nbtfile = NBTFile(fileobj=previouslyopenedfile)
or....
nbtfile = NBTFile(buffer=net_socket.makefile()) ```
Writing files
Writing files is easy too! if you have a NBTFile object, simply call it's writefile() method. If the NBTFile was instantiated with a filename, then writefile needs no extra arguments. It just works. If however you created a new file object from scratch (or even if you just want to save it somewhere else) call write_file('path\to\new\file.nbt') ```
from nbt import nbt nbtfile = nbt.NBTFile("bigtest.nbt",'rb') nbtfile["listTest (compound)"].tags[0]["name"].value = "Different name" nbtfile.write_file("newnbtfile.nbt") ```
It is also possible to write to a buffer or fileobj using the same keyword args. ```
nbtfile.writefile(fileobj = myfile) #compressed nbtfile.write_file(buffer = sock.makefile()) #uncompressed ```
Creating files
Creating files is trickier but ultimately should give you no issue, as long as you have read the NBT spec (hint.. it's very short). Also be sure to note that the NBTFile object is actually a TAG_Compound with some wrapper features, so you can use all the standard tag features ```
from nbt.nbt import * nbtfile = NBTFile() ```
First, don't forget to name the top level tag ```
nbtfile.name = "My Top Level Tag" nbtfile.tags.append(TAGFloat(name="My Float Name", value=3.152987593947)) mylist = TAGList(name="TestList", type=TAGLong) #type needs to be pre-declared! mylist.tags.append(TAGLong(100)) mylist.tags.extend([TAGLong(120),TAGLong(320),TAGLong(19)]) nbtfile.tags.append(mylist) print(nbtfile.prettytree()) TAGCompound("My Top Level Tag"): 2 Entries { TAGFloat("My Float Name"): 3.15298759395 TAGList("TestList"): 4 entries of type TAGLong { TAGLong: 100 TAGLong: 120 TAGLong: 320 TAGLong: 19 } } nbtfile["TestList"].tags.sort(key = lambda tag: tag.value) print(nbtfile.prettytree()) TAGCompound("My Top Level Tag"): 2 Entries { TAGFloat("My FloatName"): 3.15298759395 TAGList("TestList"): 4 entries of type TAGLong { TAGLong: 19 TAGLong: 100 TAGLong: 120 TAGLong: 320 } } nbtfile.writefile("mynbt.dat") ```
Owner
- Name: Thomas Woolford
- Login: twoolie
- Kind: user
- Location: Adelaide, Australia
- Company: Simbiant
- Repositories: 24
- Profile: https://github.com/twoolie
GitHub Events
Total
- Issues event: 1
- Watch event: 7
- Issue comment event: 9
- Fork event: 2
Last Year
- Issues event: 1
- Watch event: 7
- Issue comment event: 9
- Fork event: 2
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Freek Dijkstra | f****k@m****l | 230 |
| Brooks Boyd | b****b@m****s | 25 |
| Thomas Woolford | r****s@g****m | 24 |
| Alejandro Aguilera | f****n@l****m | 23 |
| Trenton Holmes | h****n@g****m | 18 |
| mfld-fr | g****b@m****r | 14 |
| Thomas Woolford | w****s@g****m | 13 |
| David Walker | d****s@g****m | 10 |
| Corbin Simpson | M****e@g****m | 4 |
| jlsajfj | j****j@h****m | 4 |
| Freek Dijkstra | p****c@m****l | 4 |
| Jamie Fraser | f****e@f****g | 3 |
| Surest Texas | s****0 | 3 |
| Sylvain Leroux | s****n@c****r | 2 |
| einekratzekatze | 4****e | 2 |
| Thomas Roesner | t****b@d****e | 2 |
| Damien Gaignon | d****n@g****m | 2 |
| Spencer Bliven | s****n@u****u | 1 |
| kamyu2 | k****2@g****m | 1 |
| Spongecade | s****9@g****m | 1 |
| Zachy | Z****d@o****m | 1 |
| Steffen Kieß | S****s@i****e | 1 |
| Corbin Simpson | s****o@o****g | 1 |
| k1988 | z****8@g****m | 1 |
| underscoren | m****s@o****m | 1 |
| Xgkkp | m****r@g****m | 1 |
| mkuw | 4****w | 1 |
| Tom Davidson | t****m@d****k | 1 |
| mfld.fr | m****r@g****m | 1 |
| Benjamin Singleton | b****n@B****t | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 69
- Total pull requests: 50
- Average time to close issues: about 1 year
- Average time to close pull requests: 5 months
- Total issue authors: 50
- Total pull request authors: 28
- Average comments per issue: 2.35
- Average comments per pull request: 2.16
- Merged pull requests: 30
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- macfreek (8)
- s-leroux (4)
- alex4200 (4)
- SupraSummus (3)
- Omeganx (2)
- ghost (2)
- jason-green-io (2)
- misode (2)
- donno (1)
- 9NONAGON (1)
- Gameligo (1)
- KingOfTNT10 (1)
- un-pogaz (1)
- skyblockz (1)
- julianprincipe (1)
Pull Request Authors
- mfld-fr (8)
- SupraSummus (7)
- macfreek (5)
- jlsajfj (3)
- steffen-kiess (2)
- admin-else (2)
- suresttexas00 (2)
- fwaggle (2)
- Tom-Davidson (1)
- Fenixin (1)
- mkuw (1)
- Netherwhal (1)
- underscoren (1)
- bsinglet (1)
- einekratzekatze (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 9,970 last-month
-
Total dependent packages: 4
(may contain duplicates) -
Total dependent repositories: 35
(may contain duplicates) - Total versions: 13
- Total maintainers: 2
pypi.org: sparragon
Python library to interact with Galaxy Life
- Homepage: http://github.com/twoolie/NBT
- Documentation: https://sparragon.readthedocs.io/
- License: GPL
-
Latest release: 0.0.3
published almost 4 years ago
Rankings
pypi.org: nbt
Named Binary Tag Reader/Writer
- Homepage: http://github.com/twoolie/NBT
- Documentation: https://nbt.readthedocs.io/
- License: Copyright (c) 2010-2013 Thomas Woolford and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 1.5.1
published over 4 years ago
