Fixup failed enemy type conversions

--8<--
#!/usr/bin/env python

import sys
import os
import random

from lxml import etree

def replaceEnemyType(xmlroot, name, newname, filename):
	for obj in xmlroot.iterchildren(tag="objectgroup"):
		if obj.get('name') == 'enemy':
			for enemy in obj:
				t = enemy.get('type')
				if t == None:
					print "No enemy type set in ", filename
					raise
				if t == name:
					enemy.set('type', newname)
					t = enemy.get('type')
	return xmlroot

def getXMLRoot(filename):
	f = open(filename)
	lines = f.read()
	f.close()
	root = etree.fromstring(lines)
	return root

def writeXML(filename, root):
	f=open(filename, 'w')
	f.write(etree.tostring(root, pretty_print=True, xml_declaration=True, encoding='utf-8'))
	f.close()

def processMap(filename):
	root = getXMLRoot(filename)
	for enemyRepl in enemyReplacements:
		root = replaceEnemyType(root, enemyRepl[0], enemyRepl[1], filename)
	writeXML(filename, root)

enemyReplacements=[
("enemies/scathelocke", "enemies/scathelocke.txt"),
("enemies/antlion_burster", "enemies/antlion_burster.txt"),
("enemies/zombie_brute", "enemies/zombie_brute.txt"),
("enemies/antlion_spitter", "enemies/antlion_spitter.txt"),
("enemies/zombie_iceclaw", "enemies/zombie_iceclaw.txt"),
("enemies/antlion_blinker", "enemies/antlion_blinker.txt"),
];

lines = open("maps.txt").readlines()
for map in lines:
	processMap(map.strip())