-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
41 lines (39 loc) · 1.27 KB
/
setup.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
from setuptools import setup, Command
from jnbt import VERSION
class Codegen( Command ):
user_options = [
( "unsafe", None, "Generate an unsafe variant of NBTWriter" )
]
boolean_options = [ "unsafe" ]
def initialize_options( self ):
self.unsafe = None
def finalize_options( self ):
self.safe = ( self.unsafe != True )
del self.unsafe
def run( self ):
with open( "template/writer.py", "r" ) as fin:
with open( "jnbt/writer.py", "w", newline="\n" ) as fout:
echo = True
line = fin.readline()
while line != "":
ls = line.strip()
if ls == "#if safe":
echo = self.safe
elif ls == "#else":
echo = not self.safe
elif ls == "#end":
echo = True
elif echo:
fout.write( line )
line = fin.readline()
setup(
name = "jnbt",
version = VERSION,
author = "theJ89",
description = "theJ89's NBT Library",
packages = [ "jnbt", "jnbt.mc", "jnbt.mc.world" ],
zip_safe = True,
cmdclass = {
"codegen": Codegen
}
)