summaryrefslogtreecommitdiff
path: root/tmx_converter.py
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-02-05 12:44:06 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-02-05 12:44:59 -0800
commit2ce632c222abaa0bf8e11fdbb8f280cc332b60a2 (patch)
tree5fc0fb2c03d56cdda75221c3f56b2360d326f0c0 /tmx_converter.py
parent370f42c1449395ad573bd418ab8c60ce734da88d (diff)
downloadtools-2ce632c222abaa0bf8e11fdbb8f280cc332b60a2.tar.gz
tools-2ce632c222abaa0bf8e11fdbb8f280cc332b60a2.tar.bz2
tools-2ce632c222abaa0bf8e11fdbb8f280cc332b60a2.tar.xz
tools-2ce632c222abaa0bf8e11fdbb8f280cc332b60a2.zip
make tmx_converter compatible with python 2.6
Diffstat (limited to 'tmx_converter.py')
-rwxr-xr-xtmx_converter.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/tmx_converter.py b/tmx_converter.py
index 4d4f36e..a9dc929 100755
--- a/tmx_converter.py
+++ b/tmx_converter.py
@@ -34,12 +34,12 @@ import zlib
dump_all = False # wall of text
# lower case versions of everything except 'spawn' and 'warp'
-other_object_types = {
+other_object_types = set([
'particle_effect',
'npc', # not interpreted by client
'script', # for ManaServ
'fixme', # flag for things that didn't have a type before
-}
+])
# Somebody has put ManaServ fields in our data!
other_spawn_fields = (
@@ -117,7 +117,7 @@ class ContentHandler(xml.sax.ContentHandler):
self.locator = None
self.out = open(out, 'w')
self.state = State.INITIAL
- self.tilesets = {0} # consider the null tile as its own tileset
+ self.tilesets = set([0]) # consider the null tile as its own tileset
self.buffer = bytearray()
self.encoding = None
self.compression = None
@@ -268,7 +268,7 @@ class ContentHandler(xml.sax.ContentHandler):
for x in self.buffer.split(','):
self.out.write(chr(int(x) not in self.tilesets))
elif self.encoding == u'base64':
- data=base64.b64decode(self.buffer)
+ data = base64.b64decode(str(self.buffer))
if self.compression == u'zlib':
data = zlib.decompress(data)
elif self.compression == u'gzip':
@@ -314,10 +314,10 @@ def main(argv):
this_map_npc_dir = posixpath.join(npc_dir, base)
os.path.isdir(this_map_npc_dir) or os.mkdir(this_map_npc_dir)
print('Converting %s to %s' % (tmx, wlk))
- with open(posixpath.join(this_map_npc_dir, NPC_MOBS), 'w') as mobs, \
- open(posixpath.join(this_map_npc_dir, NPC_WARPS), 'w') as warps, \
- open(posixpath.join(this_map_npc_dir, NPC_IMPORTS), 'w') as imports:
- xml.sax.parse(tmx, ContentHandler(wlk, this_map_npc_dir, mobs, warps, imports))
+ with open(posixpath.join(this_map_npc_dir, NPC_MOBS), 'w') as mobs:
+ with open(posixpath.join(this_map_npc_dir, NPC_WARPS), 'w') as warps:
+ with open(posixpath.join(this_map_npc_dir, NPC_IMPORTS), 'w') as imports:
+ xml.sax.parse(tmx, ContentHandler(wlk, this_map_npc_dir, mobs, warps, imports))
npc_master.append('import: %s\n' % posixpath.join(SERVER_NPCS, base, NPC_IMPORTS))
with open(posixpath.join(npc_dir, NPC_MASTER_IMPORTS), 'w') as out: