Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_layer(tilesets, node):
"""
parse a layer element and return a layer object
tilesets is required since we need to mangle gid's here
"""
layer = TiledLayer()
layer.data = []
layer.flipped_tiles = []
set_properties(layer, node)
data = None
next_gid = None
data_node = node.getElementsByTagName("data")[0]
attr = get_attributes(data_node)
if attr["encoding"] == "base64":
from base64 import b64decode
data = b64decode(bytes(data_node.lastChild.nodeValue, 'ascii'))
elif attr["encoding"] == "csv":
next_gid = map(int, "".join([line.strip() for line in data_node.lastChild.nodeValue]).split(","))