24 lines
665 B
Python
24 lines
665 B
Python
def flatten(tokens, endings, base_path):
|
|
"""
|
|
Used by
|
|
|
|
- parse.map.blocks
|
|
- parse.map.objects
|
|
- parse.tileset.gfx
|
|
- parse.spriteseheet.gfx
|
|
"""
|
|
stack = []
|
|
for name_path in tokens:
|
|
if len(name_path) == 2:
|
|
name, path = name_path
|
|
stack.append(name)
|
|
for s_name in stack:
|
|
assert any(s_name.endswith(e) for e in endings), (s_name, endings)
|
|
assert path.startswith(base_path), path
|
|
yield s_name, path
|
|
stack = []
|
|
elif len(name_path) == 1:
|
|
stack.append(name_path[0])
|
|
else:
|
|
assert False, name_path
|