def new(self): menu = QTVarios.LCMenu(self) menu.opcion("random", _("Random"), Iconos.SQL_RAW()) menu.separador() if not QTVarios.lista_db(Code.configuracion, True).is_empty(): menu.opcion("db", _("Game in a database"), Iconos.Database()) menu.separador() menu.opcion("pgn", _("Game in a pgn"), Iconos.Filtrar()) menu.separador() resp = menu.lanza() game = None if resp == "random": game = DBgames.get_random_game() elif resp == "pgn": game = Code.procesador.select_1_pgn(self) elif resp == "db": db = QTVarios.select_db(self, Code.configuracion, True, False) if db: w = PantallaDatabase.WBDatabase(self, Code.procesador, db, False, True) resp = w.exec_() if resp: game = w.game if game is None: return capture = CountsCaptures.CountCapture() capture.game = game self.db.new_count_capture(capture) self.glista.refresh()
def database(self, accion, dbpath, temporary=False): if accion == "M": if Code.is_windows: os.startfile(self.configuration.folder_databases()) return if accion == "N": dbpath = WDB_Games.new_database(self.main_window, self.configuration) if dbpath is None: return accion = "R" if accion == "D": resp = QTVarios.select_db(self.main_window, self.configuration, True, False) if resp: if QTUtil2.pregunta( self.main_window, "%s\n%s" % (_("Do you want to remove?"), resp)): Util.remove_file(resp) Util.remove_file(resp + ".st1") return if accion == "R": self.configuration.set_last_database(Util.relative_path(dbpath)) w = WindowDatabase.WBDatabase(self.main_window, self, dbpath, temporary, False) if self.main_window: if w.exec_(): if w.reiniciar: self.database("R", self.configuration.get_last_database()) else: w.show()
def import_db(self): path_db = QTVarios.select_db(self.wpolyglot, self.configuration, True, False) if not path_db: return titulo = "%s %s" % (_("Import"), os.path.basename(path_db)) resp = self.import_polyglot_config(titulo) if resp is None: return plies, st_side, st_results, ru, min_games, min_score, calc_weight, save_score, collisions = resp db = UtilSQL.DictBig() def fsum(keymove, pt): num, pts = db.get(keymove, (0, 0)) num += 1 pts += pt db[keymove] = num, pts dltmp = ImportarPGNDB(self.wpolyglot, os.path.basename(path_db)) dltmp.show() db_games = DBgames.DBgames(path_db) ok = add_db(db_games, plies, st_results, st_side, ru, time.time, 1.2, dltmp.dispatch, fsum) dltmp.close() if not ok: db.close() db_games.close() return self.merge(db, min_games, min_score, calc_weight, save_score, collisions)
def import_db(self): path_db = QTVarios.select_db(self, self.configuracion, True, False) if not path_db: return um = QTUtil2.unMomento(self, _("Working...")) li_fens = [] datadb = DBgames.DBgames(path_db) if "FEN" in datadb.li_tags(): for reg in datadb.yieldData(["FEN"], "FEN <> ''"): li_fens.append(reg.FEN) self.import_lifens("db", li_fens, um)
def tw_select_other(self): resp = QTVarios.select_db(self, self.configuration, False, True) if resp: if resp == ":n": dbpath = WDB_Games.new_database(self, self.configuration) if dbpath is not None: self.configuration.set_last_database(dbpath) self.reinit() else: self.configuration.set_last_database(resp) self.reinit()
def importarSummary(self, game): nomfichgames = QTVarios.select_db(self, self.configuration, True, False) if nomfichgames: dicData = self.import_param_books(_("Database summary"), False) if dicData: ficheroSummary = nomfichgames + ".st1" depth, siWhite, onlyone, minMoves = (dicData["DEPTH"], dicData["SIWHITE"], dicData["ONLYONE"], dicData["MINMOVES"]) self.dbop.importarSummary(self, game, ficheroSummary, depth, siWhite, onlyone, minMoves) self.glines.refresh() self.glines.gotop()
def tw_importar_DB(self): path = QTVarios.select_db(self, self.configuracion, False, False) if not path: return None dlTmp = QTVarios.ImportarFicheroDB(self) if self.dbGames.allows_duplicates: dlTmp.hide_duplicates() dlTmp.show() dbn = DBgames.DBgames(path) self.dbGames.appendDB(dbn, range(dbn.all_reccount()), dlTmp) self.rehaz_columnas() self.actualiza(True) if self.wsummary: self.wsummary.reset()
def tw_exportar_db(self, lista): dbpath = QTVarios.select_db(self, self.configuracion, False, True) if not dbpath: return if dbpath == ":n": dbpath = new_database(self, self.configuracion) if dbpath is None: return dlTmp = QTVarios.ImportarFicheroDB(self) dlTmp.ponExportados() dlTmp.show() dbn = DBgames.DBgames(dbpath) if dbn.allows_duplicates: dlTmp.hide_duplicates() dbn.appendDB(self.dbGames, lista, dlTmp)
def creaTab(self): menu = QTVarios.LCMenu(self) menu.opcion("book", _("Polyglot book"), Iconos.Libros()) menu.separador() menu.opcion("dbase", _("Database"), Iconos.Database()) # menu.separador() # menu.opcion("tree", _("Tree"), Iconos.Arbol()) resp = menu.lanza() pos = 0 if resp == "book": book = self.seleccionaLibro() if book: tabbook = TabBook(self, book, self.configuration) self.li_tabs.append((resp, tabbook)) pos = len(self.li_tabs) - 1 self.tabs.nuevaTab(tabbook, book.name, pos) self.tabs.setTabIcon(pos, Iconos.Libros()) self.setPosicion(self.game, self.njg, pos) # elif resp == "tree": # tabtree = TabTree(self, self.configuration) # self.li_tabs.append(("tree", tabtree)) # pos = len(self.li_tabs)-1 # self.tabs.nuevaTab(tabtree, _("Tree"), pos) # self.tabs.setTabIcon(pos, Iconos.Arbol()) # tabtree.bt_update() elif resp == "dbase": nomfichgames = QTVarios.select_db(self, self.configuration, True, False) if nomfichgames: db_stat = DBgamesST.TreeSTAT(nomfichgames + ".st1") tabdb = TabDatabase(self, self.procesador, db_stat) self.li_tabs.append((resp, tabdb)) pos = len(self.li_tabs) - 1 self.setPosicion(self.game, self.njg, pos) name = os.path.basename(nomfichgames)[:-5] self.tabs.nuevaTab(tabdb, name, pos) self.tabs.setTabIcon(pos, Iconos.Database()) self.tabs.activa(pos)
def gm_save_database(self): if self.torneo.num_games_finished() > 0: dbpath = QTVarios.select_db(self, self.configuration, False, True, remove_autosave=True) if dbpath is None: return if dbpath == ":n": dbpath = WDB_Games.new_database(self, self.configuration) if dbpath is None: return um = QTUtil2.unMomento(self, _("Saving...")) db = DBgames.DBgames(dbpath) for gm in self.torneo.db_games_finished: game = Game.Game() game.restore(gm.game_save) db.insert(game) um.final() db.close() QTUtil2.mensajeTemporal(self, _("Saved"), 1.2)
def new(self): menu = QTVarios.LCMenu(self) if not QTVarios.lista_db(self.configuration, True).is_empty(): menu.opcion("db", _("Game in a database"), Iconos.Database()) menu.separador() menu.opcion("pgn", _("Game in a pgn"), Iconos.Filtrar()) menu.separador() resp = menu.lanza() game = None if resp == "pgn": game = self.procesador.select_1_pgn(self) elif resp == "db": db = QTVarios.select_db(self, self.configuration, True, False) if db: w = WindowDatabase.WBDatabase(self, self.procesador, db, False, True) resp = w.exec_() if resp: game = w.game if game and len(game) > 0: reg = {"GAME": game.save()} self.db.append(reg) self.grid.refresh() self.grid.gotop()