def __init__(self): self.pokedex = pokedex.get_instance() self.evolutions = evolution.get_instance() self.models = { "national": Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, str, str, str, str), "Kdex": Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, str, str, str, str), "Jdex": Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, str, str, str, str), "Hdex": Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, str, str, str, str), "Sdex": Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, str, str, str, str), "Udex": Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, str, str, str, str), "evolution": Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, GdkPixbuf.Pixbuf, str), "prevolution": Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, GdkPixbuf.Pixbuf, str) } self.models["evolution"].set_sort_func(2, sort) self.builder = None # Read settings and open last open file. self.config = io.read_config() # If we can find the file, load it. if "filename" in self.config: filename = self.config["filename"] if os.path.exists(filename): self.pokedex.filename = filename self.filter = int(self.config.get("filter", 0b111))
def __init__(self): self.evo = {"evolution": [], "prevolution": []} dex = pokedex.get_instance().dex data = open("data/evo.dat") for line in data: entry = line.split() # pokedex unfortunately doesn't have a placeholder at 0 self.evo["evolution"].append({ "old": dex[int(entry[0]) - 1], "method": expand(entry[1]), "new": dex[int(entry[2]) - 1] }) self.evo["prevolution"].append({ "old": dex[int(entry[2]) - 1], "method": "Breed normally", "new": dex[int(entry[0]) - 1] }) data.close() data = open("data/prevo.dat") for line in data: entry = line.split() parents = entry[0].split(",") for parent in parents: for prevo in self.evo["prevolution"]: if prevo["old"] == parent: prevo["method"] = entry[1] data.close()
def read_dex(filename): """Loads the pokedex stored in filename into pyDex.""" print("Reading from %s" % filename) userdex = [0] dex = pokedex.get_instance() with open(filename) as dex_file: # Read the game version game = dex_file.readline().strip() if game in pokedex.GAME_DATA: dex.max_dex = pokedex.MAX_DEXEN[pokedex.GAME_DATA[game]["gen"]] dex.game = game dex.gen = pokedex.GAME_DATA[game]["gen"] dex.region = pokedex.GAME_DATA[game]["region"] try: while True: line = dex_file.readline().strip() if len(line) == 0: break if len(userdex) > dex.max_dex: continue userdex.append(int(line)) # Read the Unown code dex.unown_code = int(dex_file.readline()) except ValueError: print("Old config file has no unown code.") dex.unown_code = 0 except StopIteration: print("Error reading file! Only %d read." % len(userdex)) # Premature stopping or older files may result in short arrays. while len(userdex) <= dex.max_dex: userdex.append(1) return userdex