1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
map_names = {} def read_map_names(file='db/mapnames.txt'): with open(file) as f: for l in f.readlines(): try: index = l.index(' ') map_id = l[:index] map_name = l[index + 1:-1] map_names[map_id] = map_name except ValueError: pass return map_names if len(map_names) < 1: read_map_names()