Python newbie here (arent you lucky!), I can't seem to get .write_file() to work, tried on both a win7 and a ubuntu box, it creates the file but nothing gets written too it. Same happens with other files i try
heres what i get with the example (-editing that one line):
>>> import nbt
>>> nbtfile = nbt.NBTFile("bigtest.nbt",'rb')
>>> nbtfile.write_file("newnbtfile.nbt")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nbt.py", line 269, in write_file
self.type._render_buffer(file)
File "nbt.py", line 54, in _render_buffer
buffer.write(pack(self.unpack_as, self.value))
AttributeError: 'NoneType' object has no attribute 'write'
Python newbie here (arent you lucky!), I can't seem to get .write_file() to work, tried on both a win7 and a ubuntu box, it creates the file but nothing gets written too it. Same happens with other files i try
Python guru, here, and I'm having the same problem. I'll see about fixing it myself. If tWoolie doesn't offer an official fix, I'll fork it on Github and continue tinkering with it.
Hi guys, sorry i haven't been around much, i really need to set notification on this thread...
As far as i know, this issue has been fixed for a while (read: since ProfMobius PM'd me Oct 11th, fixed Oct 12th)
Official fix is in the github repo, and this fix plus more have been pushed to the 0.5 release on PyPI. (pip install NBT to install super easily :biggrin.gif:)\
As always, i look forward to hearing any more issues you guys have and i'll see if i can resolve them.
I'm with Mine_Ender: A zero-length string should be "", not None. That representation would eliminate a lot of the special cases in your code, too. Actually, I should probably just send a patch.
Pepijn de Vos has used NBT to create a script to graph the ingredients of a map according to depth. I've forked it to a shell script where you can specify which blocks you want to show.
This is a great resource. Thanks for making it available.
I easy installed the most recent version of the NBT module a couple of days ago. I can read nbt files fine but I am having trouble writing files. File writing proceeds without throwing up any errors. However, I am unable to subsequently read nbt files created with the write_file() function.
Could you please take a moment to look at the following output and advise me what I should be doing? The test below uses the standard bigtest.nbt test data.
>>> nbtfile = nbt.NBTFile("bigtest.nbt",'rb')
>>> nbtfile.write_file("newnbtfile.nbt")
>>> newnbtfile = nbt.NBTFile("newnbtfile.nbt",'rb')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
newnbtfile = nbt.NBTFile("newnbtfile.nbt",'rb')
File "build\bdist.win32\egg\nbt\nbt.py", line 249, in __init__
self.parse_file(self.file)
File "build\bdist.win32\egg\nbt\nbt.py", line 258, in parse_file
type = TAG_Byte(buffer=file)
File "build\bdist.win32\egg\nbt\nbt.py", line 46, in __init__
self._parse_buffer(buffer)
File "build\bdist.win32\egg\nbt\nbt.py", line 50, in _parse_buffer
self.value = unpack(self.fmt, buffer.read(self.size))[0]
error: unpack requires a string argument of length 1
>>>
After investigation i can see that the problem is that files are not properly closed at the end of write_file().
This never shows up in the test cases because the python interpreter has access to the buffer.
quick fix for you: paste
if 'close' in dir(self.file): self.file.close()
in at the end of write_file() and a fix for this issue will be in the next official release.
i'd love to see what people get up to with it!
http://github.com/twoolie/NBT
*NEW!* submitted to PyPI - Easy downloads with PIP/easy_install
http://pypi.python.org/pypi/NBT
Feature requests welcome!
Props to aheadly for giving NBT a use in pynemap
EDIT: have subscribed to thread, so should get back to you guys earlier
Feature requests are welcome btw
The TAG_String parser contains a clause that checks the string length and returns None if the string is zero length. is this what you mean by bug?
heres what i get with the example (-editing that one line):
Python guru, here, and I'm having the same problem. I'll see about fixing it myself. If tWoolie doesn't offer an official fix, I'll fork it on Github and continue tinkering with it.
As far as i know, this issue has been fixed for a while (read: since ProfMobius PM'd me Oct 11th, fixed Oct 12th)
Official fix is in the github repo, and this fix plus more have been pushed to the 0.5 release on PyPI. (pip install NBT to install super easily :biggrin.gif:)\
As always, i look forward to hearing any more issues you guys have and i'll see if i can resolve them.
Thomas
To install this on Ubuntu with all dependencies:
l0b0: awesome! really glad to hear it!
I easy installed the most recent version of the NBT module a couple of days ago. I can read nbt files fine but I am having trouble writing files. File writing proceeds without throwing up any errors. However, I am unable to subsequently read nbt files created with the write_file() function.
Could you please take a moment to look at the following output and advise me what I should be doing? The test below uses the standard bigtest.nbt test data.
After investigation i can see that the problem is that files are not properly closed at the end of write_file().
This never shows up in the test cases because the python interpreter has access to the buffer.
quick fix for you: paste in at the end of write_file() and a fix for this issue will be in the next official release.