Skip to content

Commit

Permalink
Change indentation tabs to spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
macfreek committed Oct 27, 2013
1 parent dc3844d commit 2cd96eb
Show file tree
Hide file tree
Showing 23 changed files with 3,950 additions and 3,942 deletions.
8 changes: 8 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ See https://github.com/twoolie/NBT/issues
or compile Python --with-wide-unicode.


NBT 1.4.1 (27 October 2013)
---------------------------

New Features since 1.4.0
~~~~~~~~~~~~~~~~~~~~~~~~
* Change indentation from tabs to spaces.


NBT 1.4.0 (27 October 2013)
---------------------------

Expand Down
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
# in the site-packages
parentdir = os.path.abspath(os.path.join(os.path.dirname(__file__),os.pardir))
if not os.path.exists(os.path.join(parentdir, 'nbt')):
raise ImportError("Can not find nbt module at %s" % parentdir)
raise ImportError("Can not find nbt module at %s" % parentdir)
if os.path.exists(os.path.join(parentdir, 'examples')):
sys.path.insert(1, os.path.join(parentdir, 'examples'))
sys.path.insert(1, os.path.join(parentdir, 'examples'))
if os.path.exists(os.path.join(parentdir, 'tests')):
sys.path.insert(1, os.path.join(parentdir, 'tests'))
sys.path.insert(1, os.path.join(parentdir, 'tests'))
sys.path.insert(1, parentdir)
# setuptools (which is used by pip) sometimes places a .pth file in the
# site-package folder which overrides sys.path by manipulating sys.modules.
Expand Down
18 changes: 9 additions & 9 deletions doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ Examples
========

**Block Analysis**
*Current Status:*
*Current Status:*

**Chest Analysis**
*Current Status:* McRegion and Anvil maps
This example shows loading a Minecraft world, and moving through it, using a dictionary-like interface.
Tags
*Current Status:* McRegion and Anvil maps
This example shows loading a Minecraft world, and moving through it, using a dictionary-like interface.
Tags

**Generate Leve.dat**
*Current Status:*
*Current Status:*

**Map**
*Current Status:*
*Current Status:*

**Mob Analysis**
*Current Status:*
*Current Status:*

**Utilities**
*Current Status:*
*Current Status:*

**Biome Analysis**
*Current Status:* Anvil maps only
*Current Status:* Anvil maps only

98 changes: 49 additions & 49 deletions doc/specification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,56 +140,56 @@ in the TAG_Compound is over, and indeed all of the NBT file.

So we ended up with this::

TAG_Compound("hello world"): 1 entries
{
TAG_String("name"): Bananrama
}
TAG_Compound("hello world"): 1 entries
{
TAG_String("name"): Bananrama
}

For a slightly longer test, download http://www.minecraft.net/docs/bigtest.nbt.
You should end up with this::

TAG_Compound("Level"): 11 entries
{
TAG_Short("shortTest"): 32767
TAG_Long("longTest"): 9223372036854775807
TAG_Float("floatTest"): 0.49823147
TAG_String("stringTest"): HELLO WORLD THIS IS A TEST STRING ÅÄÖ!
TAG_Int("intTest"): 2147483647
TAG_Compound("nested compound test"): 2 entries
{
TAG_Compound("ham"): 2 entries
{
TAG_String("name"): Hampus
TAG_Float("value"): 0.75
}
TAG_Compound("egg"): 2 entries
{
TAG_String("name"): Eggbert
TAG_Float("value"): 0.5
}
}
TAG_List("listTest (long)"): 5 entries of type TAG_Long
{
TAG_Long: 11
TAG_Long: 12
TAG_Long: 13
TAG_Long: 14
TAG_Long: 15
}
TAG_Byte("byteTest"): 127
TAG_List("listTest (compound)"): 2 entries of type TAG_Compound
{
TAG_Compound: 2 entries
{
TAG_String("name"): Compound tag #0
TAG_Long("created-on"): 1264099775885
}
TAG_Compound: 2 entries
{
TAG_String("name"): Compound tag #1
TAG_Long("created-on"): 1264099775885
}
}
TAG_Byte_Array("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))"): [1000 bytes]
TAG_Double("doubleTest"): 0.4931287132182315
}
TAG_Compound("Level"): 11 entries
{
TAG_Short("shortTest"): 32767
TAG_Long("longTest"): 9223372036854775807
TAG_Float("floatTest"): 0.49823147
TAG_String("stringTest"): HELLO WORLD THIS IS A TEST STRING ÅÄÖ!
TAG_Int("intTest"): 2147483647
TAG_Compound("nested compound test"): 2 entries
{
TAG_Compound("ham"): 2 entries
{
TAG_String("name"): Hampus
TAG_Float("value"): 0.75
}
TAG_Compound("egg"): 2 entries
{
TAG_String("name"): Eggbert
TAG_Float("value"): 0.5
}
}
TAG_List("listTest (long)"): 5 entries of type TAG_Long
{
TAG_Long: 11
TAG_Long: 12
TAG_Long: 13
TAG_Long: 14
TAG_Long: 15
}
TAG_Byte("byteTest"): 127
TAG_List("listTest (compound)"): 2 entries of type TAG_Compound
{
TAG_Compound: 2 entries
{
TAG_String("name"): Compound tag #0
TAG_Long("created-on"): 1264099775885
}
TAG_Compound: 2 entries
{
TAG_String("name"): Compound tag #1
TAG_Long("created-on"): 1264099775885
}
}
TAG_Byte_Array("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))"): [1000 bytes]
TAG_Double("doubleTest"): 0.4931287132182315
}
134 changes: 67 additions & 67 deletions examples/biome_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,87 @@

# local module
try:
import nbt
import nbt
except ImportError:
# nbt not in search path. Let's see if it can be found in the parent folder
extrasearchpath = os.path.realpath(os.path.join(__file__,os.pardir,os.pardir))
if not os.path.exists(os.path.join(extrasearchpath,'nbt')):
raise
sys.path.append(extrasearchpath)
# nbt not in search path. Let's see if it can be found in the parent folder
extrasearchpath = os.path.realpath(os.path.join(__file__,os.pardir,os.pardir))
if not os.path.exists(os.path.join(extrasearchpath,'nbt')):
raise
sys.path.append(extrasearchpath)
from nbt.region import RegionFile
from nbt.chunk import Chunk
from nbt.world import AnvilWorldFolder,UnknownWorldFormat

BIOMES = {
0 : "Ocean",
1 : "Plains",
2 : "Desert",
3 : "Mountains",
4 : "Forest",
5 : "Taiga",
6 : "Swamp",
7 : "River",
8 : "Nether",
9 : "Sky",
10: "Frozen Ocean",
11: "Frozen River",
12: "Ice Plains",
13: "Ice Mountains",
14: "Mushroom Island",
15: "Mushroom Shore",
16: "Beach",
17: "Desert Hills",
18: "Forest Hills",
19: "Taiga Hills",
20: "Mountains Edge",
21: "Jungle",
22: "Jungle Hills",
# 255: "Not yet calculated",
0 : "Ocean",
1 : "Plains",
2 : "Desert",
3 : "Mountains",
4 : "Forest",
5 : "Taiga",
6 : "Swamp",
7 : "River",
8 : "Nether",
9 : "Sky",
10: "Frozen Ocean",
11: "Frozen River",
12: "Ice Plains",
13: "Ice Mountains",
14: "Mushroom Island",
15: "Mushroom Shore",
16: "Beach",
17: "Desert Hills",
18: "Forest Hills",
19: "Taiga Hills",
20: "Mountains Edge",
21: "Jungle",
22: "Jungle Hills",
# 255: "Not yet calculated",
}


def print_results(biome_totals):
locale.setlocale(locale.LC_ALL, '')
for id,count in enumerate(biome_totals):
# Biome ID 255 is ignored. It means it is not calculated by Minecraft yet
if id == 255 or (count == 0 and id not in BIOMES):
continue
if id in BIOMES:
biome = BIOMES[id]+" (%d)" % id
else:
biome = "Unknown (%d)" % id
print(locale.format_string("%-25s %10d", (biome,count)))
locale.setlocale(locale.LC_ALL, '')
for id,count in enumerate(biome_totals):
# Biome ID 255 is ignored. It means it is not calculated by Minecraft yet
if id == 255 or (count == 0 and id not in BIOMES):
continue
if id in BIOMES:
biome = BIOMES[id]+" (%d)" % id
else:
biome = "Unknown (%d)" % id
print(locale.format_string("%-25s %10d", (biome,count)))


def main(world_folder):
world = AnvilWorldFolder(world_folder) # Not supported for McRegion
if not world.nonempty(): # likely still a McRegion file
sys.stderr.write("World folder %r is empty or not an Anvil formatted world\n" % world_folder)
return 65 # EX_DATAERR
biome_totals = [0]*256 # 256 counters for 256 biome IDs
try:
for chunk in world.iter_nbt():
for biomeid in chunk["Level"]["Biomes"]:
biome_totals[biomeid] += 1
world = AnvilWorldFolder(world_folder) # Not supported for McRegion
if not world.nonempty(): # likely still a McRegion file
sys.stderr.write("World folder %r is empty or not an Anvil formatted world\n" % world_folder)
return 65 # EX_DATAERR
biome_totals = [0]*256 # 256 counters for 256 biome IDs
try:
for chunk in world.iter_nbt():
for biomeid in chunk["Level"]["Biomes"]:
biome_totals[biomeid] += 1

except KeyboardInterrupt:
print_results(biome_totals)
return 75 # EX_TEMPFAIL
print_results(biome_totals)
return 0 # NOERR
except KeyboardInterrupt:
print_results(biome_totals)
return 75 # EX_TEMPFAIL
print_results(biome_totals)
return 0 # NOERR


if __name__ == '__main__':
if (len(sys.argv) == 1):
print("No world folder specified!")
sys.exit(64) # EX_USAGE
world_folder = sys.argv[1]
# clean path name, eliminate trailing slashes:
world_folder = os.path.normpath(world_folder)
if (not os.path.exists(world_folder)):
print("No such folder as "+world_folder)
sys.exit(72) # EX_IOERR
sys.exit(main(world_folder))
if (len(sys.argv) == 1):
print("No world folder specified!")
sys.exit(64) # EX_USAGE
world_folder = sys.argv[1]
# clean path name, eliminate trailing slashes:
world_folder = os.path.normpath(world_folder)
if (not os.path.exists(world_folder)):
print("No such folder as "+world_folder)
sys.exit(72) # EX_IOERR
sys.exit(main(world_folder))
Loading

0 comments on commit 2cd96eb

Please sign in to comment.