forked from mcedit/pymclevel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbt.py
67 lines (66 loc) · 1.56 KB
/
nbt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import logging
logger = logging.getLogger(__file__)
try:
try:
from _nbt import (
load,
gunzip,
TAG_Byte,
TAG_Byte_Array,
TAG_Compound,
TAG_Double,
TAG_Float,
TAG_Int,
TAG_Int_Array,
TAG_List,
TAG_Long,
TAG_Short,
TAG_String
)
logger.info('Accelerated NBT module loaded.')
except ImportError:
import numpy
from pyximport import install
try:
install(setup_args={
'include_dirs': [
numpy.get_include()
]
})
except TypeError:
logger.info(
'The version of pyximport available does not support '
'`include_dirs`, which is required.'
)
from _nbt import (
load,
gunzip,
TAG_Byte,
TAG_Byte_Array,
TAG_Compound,
TAG_Double,
TAG_Float,
TAG_Int,
TAG_Int_Array,
TAG_List,
TAG_Long,
TAG_Short,
TAG_String
)
except ImportError, e:
logger.info('Accelerated NBT module unavailable, using native library.')
from pynbt import (
load,
gunzip,
TAG_Byte,
TAG_Byte_Array,
TAG_Compound,
TAG_Double,
TAG_Float,
TAG_Int,
TAG_Int_Array,
TAG_List,
TAG_Long,
TAG_Short,
TAG_String
)