Commits

Mike Bayer committed f1ce0b1

- add tests for TAG_Int_array
- seems like NBT.txt is gone, changed the link

Comments (0)

Files changed (10)

+0.2.2
+=====
+Added support for the new TAG_Int_array type, courtesy
+dratini0.
+
 0.2.1
 =====
 Fixed -n option in yaml2nbt, previously was having
 custom YAML format.   It also includes a Python API for parsing and writing NBT files to/from
 a simple Python data structure.
 
-The key tool is ``nbtedit``, a command line utility that will shell out the 
+The key tool is ``nbtedit``, a command line utility that will shell out the
 YAML version of the target NBT file to your editor of choice, allowing
 relatively easy editing of NBT data.   When the editing session is closed,
 the saved file is parsed back into NBT, and if changes have occurred, the original
 file is updated; a copy of the previous version is saved as well.
 
-NBT format:  http://www.minecraft.net/docs/NBT.txt
+NBT format:  http://wiki.vg/NBT
 
 YAML: http://www.yaml.org/
 
 Suppose we want to switch the "GameMode" from "0" (survival) to "1"
 (creative).
 
-First, ensure that Minecraft itself is **not running**.  Then, navigate to 
+First, ensure that Minecraft itself is **not running**.  Then, navigate to
 where your Minecraft save files are.  Here's how it looks on a mac::
 
     $ cd ~/Library/Application\ Support/minecraft/saves/
 very possible that an incorrectly edited YAML file could save an NBT file that Minecraft no longer
 knows how to read.
 
-**Back EVERYTHING up before tinkering with your files !!**  nbtedit saves a backup of each file it edits, but 
+**Back EVERYTHING up before tinkering with your files !!**  nbtedit saves a backup of each file it edits, but
 **don't rely solely on that!**  Please note you are **using this editor at your own risk**.   The code is
-unit tested, works great, but I'd hate to be the reason you screwed up your world so **make copies of all 
+unit tested, works great, but I'd hate to be the reason you screwed up your world so **make copies of all
 files being edited first**.  Thanks!
 
 
 [egg_info]
-tag_build = dev
 
 readme = os.path.join(os.path.dirname(__file__), 'README.rst')
 
 setup(name='nbt2yaml',
-      version="0.2.1",
+      version="0.2.2",
       description="Read and write Minecraft NBT files using Yaml.",
       long_description=file(readme).read(),
       classifiers=[
Add a comment to this file

tests/files/intarraytest.nbt

Binary file modified.

tests/files/intarraytest.yml

   - 14
   - 15
   - 16
-

tests/test_dump_nbt.py

         self._assert_data("bigtest.nbt")
 
     def test_spawner(self):
-        self._assert_data("spawner.nbt")
+        self._assert_data("spawner.nbt")
+
+    def test_int_array(self):
+        self._assert_data("intarraytest.nbt")

tests/test_dump_yaml.py

         data = parse_nbt(datafile("spawner.nbt"))
         eq_(dump_yaml(data), datafile("spawner.yml").read())
 
+    def test_int_array(self):
+        data = parse_nbt(datafile("intarraytest.nbt"))
+        eq_(dump_yaml(data), datafile("intarraytest.yml").read())
+
     def test_large(self):
         data = parse_nbt(datafile("bigtest.nbt"))
         eq_(dump_yaml(data),

tests/test_parse_nbt.py

 class ParseNBTTest(unittest.TestCase):
     def test_basic(self):
         assert_ = (
-                    parse.TAG_Compound, 
-                    u'hello world', 
+                    parse.TAG_Compound,
+                    u'hello world',
                     [(parse.TAG_String, u'name', u'Bananrama')]
                 )
         eq_(parse_nbt(datafile("test.nbt")), assert_)
     def test_large(self):
         assert_ = (
                     parse.TAG_Compound, u'Level', [
-                        (parse.TAG_Long, u'longTest', 9223372036854775807L), 
-                        (parse.TAG_Short, u'shortTest', 32767), 
-                        (parse.TAG_String, u'stringTest', u'HELLO WORLD THIS IS A TEST STRING \xc5\xc4\xd6!'), 
-                        (parse.TAG_Float, u'floatTest', 0.4982314705848694), 
-                        (parse.TAG_Int, u'intTest', 2147483647), 
-                        (parse.TAG_Compound, u'nested compound test', 
+                        (parse.TAG_Long, u'longTest', 9223372036854775807L),
+                        (parse.TAG_Short, u'shortTest', 32767),
+                        (parse.TAG_String, u'stringTest', u'HELLO WORLD THIS IS A TEST STRING \xc5\xc4\xd6!'),
+                        (parse.TAG_Float, u'floatTest', 0.4982314705848694),
+                        (parse.TAG_Int, u'intTest', 2147483647),
+                        (parse.TAG_Compound, u'nested compound test',
                             [
-                                (parse.TAG_Compound, u'ham', 
+                                (parse.TAG_Compound, u'ham',
                                     [
-                                        (parse.TAG_String, u'name', u'Hampus'), 
+                                        (parse.TAG_String, u'name', u'Hampus'),
                                         (parse.TAG_Float, u'value', 0.75)
-                                    ]), 
-                                    (parse.TAG_Compound, u'egg', 
+                                    ]),
+                                    (parse.TAG_Compound, u'egg',
                                     [
-                                        (parse.TAG_String, u'name', u'Eggbert'), 
+                                        (parse.TAG_String, u'name', u'Eggbert'),
                                         (parse.TAG_Float, u'value', 0.5)
                                     ])
-                                ]), 
-                                (parse.TAG_List, u'listTest (long)', (parse.TAG_Long, [11, 12, 13, 14, 15])), 
-                    (parse.TAG_List, u'listTest (compound)', 
+                                ]),
+                                (parse.TAG_List, u'listTest (long)', (parse.TAG_Long, [11, 12, 13, 14, 15])),
+                    (parse.TAG_List, u'listTest (compound)',
                         (parse.TAG_Compound, [
                             [
-                                (parse.TAG_String, u'name', u'Compound tag #0'), 
+                                (parse.TAG_String, u'name', u'Compound tag #0'),
                                 (parse.TAG_Long, u'created-on', 1264099775885L)
-                            ], 
+                            ],
                             [
-                                (parse.TAG_String, u'name', u'Compound tag #1'), 
+                                (parse.TAG_String, u'name', u'Compound tag #1'),
                                 (parse.TAG_Long, u'created-on', 1264099775885L)
                             ]
-                        ])), 
-                        (parse.TAG_Byte, u'byteTest', 127), 
-                        (parse.TAG_Byte_Array, 
+                        ])),
+                        (parse.TAG_Byte, u'byteTest', 127),
+                        (parse.TAG_Byte_Array,
                             u'byteArrayTest (the first 1000 values of '
                                     '(n*n*255+n*7)%100, starting with n=0 '
-                                    '(0, 62, 34, 16, 8, ...))', 
+                                    '(0, 62, 34, 16, 8, ...))',
                                     ''.join([struct.pack('>b', (n*n*255+n*7)%100) for n in range(0, 1000)])
                             ),
                         (parse.TAG_Double, u'doubleTest', 0.4931287132182315)
                     ])
         eq_(parse_nbt(datafile("bigtest.nbt")), assert_)
+
+    def test_int_array(self):
+        assert_ = (
+                    parse.TAG_Compound, 'Test root compound',
+                    [(parse.TAG_Int_Array,
+                            'Test integer array',
+                            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+                            12, 13, 14, 15, 16])])
+        eq_(parse_nbt(datafile("intarraytest.nbt")), assert_)

tests/test_parse_yaml.py

         data = parse_yaml(datafile("spawner.yml"))
         self._assert(data, "spawner.nbt")
 
+    def test_int_array(self):
+        data = parse_yaml(datafile("intarraytest.yml"))
+        self._assert(data, "intarraytest.nbt")
+
     def _assert(self, data, nbt_filename):
         eq_(data, parse_nbt(datafile(nbt_filename)))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.