def retrieve_basher_list(self,parser): basher_list = [] try: for b in parser.items('bashers'): scoord,ecoord = b sx = scoord.partition(',')[0] sy = scoord.partition(',')[2] ex = ecoord.partition(',')[0] ey = ecoord.partition(',')[2].partition(';')[0] speed = ecoord.partition(',')[2].partition(';')[2] newbasher = cMonsterBasher.cMonsterBasher(int(sx),int(sy),int(ex),int(ey),int(speed)) basher_list.append(newbasher) except: pass return basher_list
def retrieve_basher_list(self,fname): """ Get a bouncer list from a .prop file.""" with open(fname) as f: content = f.readlines() bashers = content[content.index('[bashers]\n')+1:content.index('[flies]\n')] basher_list = [] for dat in bashers: bash_n_speed = dat.rstrip("\n").split(";") bl = bash_n_speed[0].split(":") borig = bl[0].split(",") bend = bl[1].split(",") speed = int(bash_n_speed[1]) sx= borig[0] sy= borig[1] ex = bend[0] ey = bend[1] newbasher = cMonsterBasher.cMonsterBasher(int(sx),int(sy),int(ex),int(ey),int(speed)) basher_list.append(newbasher) return basher_list