Beispiel #1
0
    def read_pgn(self, fichero_pgn):
        fichero_pgn = os.path.abspath(fichero_pgn)
        cfecha_pgn = str(os.path.getmtime(fichero_pgn))
        cdir = self.configuracion.folder_databases_pgn()

        file_db = os.path.join(cdir,
                               os.path.basename(fichero_pgn)[:-4] + ".lcdb")

        if Util.exist_file(file_db):
            create = False
            db = DBgames.DBgames(file_db)
            cfecha_pgn_ant = db.recuperaConfig("PGN_DATE")
            fichero_pgn_ant = db.recuperaConfig("PGN_FILE")
            db.close()
            if cfecha_pgn != cfecha_pgn_ant or fichero_pgn_ant != fichero_pgn:
                create = True
                Util.remove_file(file_db)
        else:
            create = True

        if create:
            db = DBgames.DBgames(file_db)
            dlTmp = QTVarios.ImportarFicheroPGN(self.main_window)
            dlTmp.show()
            db.leerPGNs([fichero_pgn], dlTmp=dlTmp)
            db.guardaConfig("PGN_DATE", cfecha_pgn)
            db.guardaConfig("PGN_FILE", fichero_pgn)
            db.close()
            dlTmp.close()

        self.database("R", file_db, temporary=True)
 def show_anotar(self):
     w = WindowAnotar.WAnotar(self)
     if w.exec_():
         pc, siblancasabajo = w.resultado
         if pc is None:
             pc = DBgames.get_random_game()
         self.anotar(pc, siblancasabajo)
Beispiel #3
0
 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 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)
Beispiel #5
0
 def miniatura(self):
     file_miniatures = Code.path_resource("IntFiles", "Miniatures.lcdb")
     db = DBgames.DBgames(file_miniatures)
     db.all_reccount()
     num_game = random.randint(0, db.reccount() - 1)
     game = db.leePartidaRecno(num_game)
     db.close()
     dic = {"GAME": game.save()}
     gestor = GestorSolo.GestorSolo(self)
     gestor.inicio(dic)
Beispiel #6
0
 def miniatura(self):
     file_miniatures = Code.path_resource("IntFiles", "Miniatures.lcdb")
     db = DBgames.DBgames(file_miniatures)
     db.all_reccount()
     num_game = random.randint(0, db.reccount() - 1)
     game = db.read_game_recno(num_game)
     db.close()
     dic = {"GAME": game.save()}
     manager = ManagerSolo.ManagerSolo(self)
     manager.start(dic)
    def read_pgn(self, fichero_pgn):
        fichero_pgn = os.path.abspath(fichero_pgn)
        cfecha_pgn = str(os.path.getmtime(fichero_pgn))
        path_temp_pgns = self.configuration.folder_databases_pgn()

        li = list(os.scandir(path_temp_pgns))
        li_ant = []
        for entry in li:
            if entry.name.endswith(".lcdb"):
                li_ant.append(entry)
            else:
                Util.remove_file(entry.path)
        if len(li_ant) > 10:
            li_ant.sort(key=lambda x: x.stat()[ST_ATIME], reverse=True)
            for x in li_ant[10:]:
                Util.remove_file(x.path)

        file_db = os.path.join(path_temp_pgns,
                               os.path.basename(fichero_pgn)[:-3] + "lcdb")

        if Util.exist_file(file_db):
            create = False
            db = DBgames.DBgames(file_db)
            cfecha_pgn_ant = db.recuperaConfig("PGN_DATE")
            fichero_pgn_ant = db.recuperaConfig("PGN_FILE")
            db.close()
            if cfecha_pgn != cfecha_pgn_ant or fichero_pgn_ant != fichero_pgn:
                create = True
                Util.remove_file(file_db)
        else:
            create = True

        if create:
            db = DBgames.DBgames(file_db)
            dlTmp = QTVarios.ImportarFicheroPGN(self.main_window)
            dlTmp.show()
            db.import_pgns([fichero_pgn], dlTmp=dlTmp)
            db.save_config("PGN_DATE", cfecha_pgn)
            db.save_config("PGN_FILE", fichero_pgn)
            db.close()
            dlTmp.close()

        self.database("R", file_db, temporary=True)
Beispiel #8
0
 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 select_1_pgn(self, wparent=None):
        wparent = self.main_window if wparent is None else wparent
        path = QTVarios.select_pgn(wparent)
        if path:
            fichero_pgn = os.path.abspath(path)
            cfecha_pgn = str(os.path.getmtime(fichero_pgn))
            cdir = self.configuration.folder_databases_pgn()

            file_db = os.path.join(
                cdir,
                os.path.basename(fichero_pgn)[:-4] + ".lcdb")

            if Util.exist_file(file_db):
                create = False
                db = DBgames.DBgames(file_db)
                cfecha_pgn_ant = db.recuperaConfig("PGN_DATE")
                fichero_pgn_ant = db.recuperaConfig("PGN_FILE")
                db.close()
                if cfecha_pgn != cfecha_pgn_ant or fichero_pgn_ant != fichero_pgn:
                    create = True
                    Util.remove_file(file_db)
            else:
                create = True

            if create:
                db = DBgames.DBgames(file_db)
                dlTmp = QTVarios.ImportarFicheroPGN(wparent)
                dlTmp.show()
                db.import_pgns([fichero_pgn], dlTmp=dlTmp)
                db.save_config("PGN_DATE", cfecha_pgn)
                db.save_config("PGN_FILE", fichero_pgn)
                db.close()
                dlTmp.close()

            w = WindowDatabase.WBDatabase(self.main_window, self, file_db,
                                          True, True)
            if w.exec_():
                return w.game

        return None
Beispiel #10
0
    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()
Beispiel #11
0
    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)
Beispiel #12
0
 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)
Beispiel #13
0
    def mas(self):
        path_pgn = QTVarios.select_pgn(self)
        if not path_pgn:
            return

        path_db = self.configuration.ficheroTemporal("lcdb")
        db = DBgames.DBgames(path_db)
        dlTmp = QTVarios.ImportarFicheroPGN(self)
        dlTmp.show()
        db.import_pgns([path_pgn], dlTmp=dlTmp)
        db.close()
        dlTmp.close()

        db = DBgames.DBgames(path_db)
        nreccount = db.all_reccount()
        if nreccount == 0:
            return

        plant = ""
        shuffle = False
        reverse = False
        todos = range(1, nreccount + 1)
        li_regs = []
        max_moves = 0
        while True:
            sep = FormLayout.separador
            liGen = []
            liGen.append((None, "%s: %d" % (_("Total games"), nreccount)))
            liGen.append(sep)
            config = FormLayout.Editbox(_("Select games") + "<br>" +
                                        _("By example:") + " -5,7-9,14,19-" +
                                        "<br>" + _("Empty means all games"),
                                        rx="[0-9,\-,\,]*")
            liGen.append((config, plant))

            liGen.append(sep)

            liGen.append((_("Shuffle") + ":", shuffle))

            liGen.append(sep)

            liGen.append((_("Reverse") + ":", reverse))

            liGen.append(sep)

            config = FormLayout.Spinbox(_("Max moves"), 0, 999, 50)
            liGen.append((config, 0))

            resultado = FormLayout.fedit(liGen,
                                         title=_("Select games"),
                                         parent=self,
                                         anchoMinimo=200,
                                         icon=Iconos.Opciones())
            if resultado:
                accion, liResp = resultado
                plant, shuffle, reverse, max_moves = liResp
                if plant:
                    ln = Util.ListaNumerosImpresion(plant)
                    li_regs = ln.selected(todos)
                else:
                    li_regs = todos
                nregs = len(li_regs)
                if 12 <= nregs <= 500:
                    break
                else:
                    QTUtil2.message_error(
                        self, "%s (%d)" %
                        (_("Number of games must be in range 12-500"), nregs))
                    li_regs = None
            else:
                break

        if li_regs:
            if shuffle:
                random.shuffle(li_regs)
            if reverse:
                li_regs.sort(reverse=True)
            li_regs = [x - 1 for x in li_regs]  # 0 init

            dic = {}
            dic["TOURNEY"] = os.path.basename(path_pgn)[:-4]
            games = dic["GAMES"] = []

            for recno in li_regs:
                g = db.read_game_recno(recno)
                pv = g.pv()
                if max_moves:
                    lipv = pv.strip().split(" ")
                    if len(lipv) > max_moves:
                        pv = " ".join(lipv[:max_moves])
                dt = {"LABELS": g.li_tags, "XPV": FasterCode.pv_xpv(pv)}
                games.append(dt)

            self.litourneys.append(dic)

            li = [("%s (%d)" % (tourney["TOURNEY"], len(tourney["GAMES"])),
                   tourney) for tourney in self.litourneys]
            self.cbtourney.rehacer(li, dic)

        db.close()
Beispiel #14
0
    def __init__(self, w_parent, procesador, file_database, is_temporary,
                 si_select):
        self.is_temporary = is_temporary
        icono = Iconos.Database()
        extparam = "databases"
        titulo = _("Temporary database") if self.is_temporary else _(
            "Database")
        QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam)
        self.owner = w_parent

        self.procesador = procesador
        self.configuration = procesador.configuration

        self.reiniciar = False  # lo usamos para cambiar de database

        self.dbGames = DBgames.DBgames(file_database)

        self.dicvideo = self.restore_dicvideo()
        dicVideo = self.dicvideo

        siSummary = not si_select

        self.wplayer = WDB_Players.WPlayer(procesador, self, self.dbGames)
        self.wplayer_active = False

        if siSummary:
            self.wsummary = WDB_Summary.WSummary(procesador,
                                                 self,
                                                 self.dbGames,
                                                 siMoves=False)
            self.register_grid(self.wsummary.grid)

        else:
            self.wsummary = None

        self.wgames = WDB_Games.WGames(procesador, self, self.dbGames,
                                       self.wsummary, si_select)

        self.ultFocus = None

        self.tab = Controles.Tab()
        self.tab.nuevaTab(self.wgames, _("Games"))
        if siSummary:
            self.tab.nuevaTab(self.wsummary, _("Summary"))
            self.tab.dispatchChange(self.tabChanged)
        if not si_select:
            self.tab.nuevaTab(self.wplayer, _("Players"))
        self.tab.ponTipoLetra(puntos=procesador.configuration.x_tb_fontpoints)

        if self.owner and not self.is_temporary:
            liAccionesWork = [(_("Select other"), Iconos.Database(),
                               self.tw_select_other)]
            self.tbWork = QTVarios.LCTB(self, liAccionesWork, icon_size=20)
            self.tbWork.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
            self.tab.setCornerWidget(self.tbWork)

        w = QtWidgets.QWidget(self)
        layoutv = Colocacion.V().control(self.tab).margen(4)
        w.setLayout(layoutv)

        self.infoMove = WDB_InfoMove.WInfomove(self)

        self.splitter = splitter = QtWidgets.QSplitter()
        splitter.addWidget(w)
        splitter.addWidget(self.infoMove)

        layout = Colocacion.H().control(splitter).margen(0)
        self.setLayout(layout)

        self.restore_video(anchoDefecto=1200, altoDefecto=600)
        if not dicVideo:
            dicVideo = {
                "SPLITTER": [800, 380],
                "TREE_1": 25,
                "TREE_2": 25,
                "TREE_3": 50,
                "TREE_4": 661
            }

        if not ("SPLITTER" in dicVideo):
            ancho = self.width()
            ancho_board = self.infoMove.board.width()
            sz = [ancho - ancho_board, ancho_board]
        else:
            sz = dicVideo["SPLITTER"]
        self.splitter.setSizes(sz)

        dic_grid = self.dbGames.read_config("dic_grid")
        if not dic_grid:
            key = "databases_columns_default"
            dic_grid = self.configuration.read_variables(key)
        if dic_grid:
            self.wgames.grid.restore_video(dic_grid)
            self.wgames.grid.releerColumnas()

        self.inicializa()
Beispiel #15
0
    def save(self):
        name = self.ed_name.texto().strip()
        if not name:
            QTUtil2.message_error(self, _("You must indicate a name"))
            return

        folder = self.configuracion.folder_databases()
        group = self.ed_group.texto()
        if group:
            folder = os.path.join(folder, group)
            subgroup_l1 = self.ed_subgroup_l1.texto()
            if subgroup_l1:
                folder = os.path.join(folder, subgroup_l1)
                subgroup_l2 = self.ed_subgroup_l2.texto()
                if subgroup_l2:
                    folder = os.path.join(folder, subgroup_l2)
        if not Util.exist_folder(folder):
            try:
                os.makedirs(folder, True)
            except:
                QTUtil2.message_error(self, "%s\n%s" % (_("Unable to create folder"), folder))
                return

        filename = "%s.lcdb" % name
        if self.external_folder:
            filepath = os.path.join(self.external_folder, filename)
        else:
            filepath = os.path.join(folder, filename)

        test_exist = self.new
        if not self.new:
            previous = self.dic_data["FILEPATH"]
            test_exist = not Util.same_path(previous, filepath)

        if test_exist and Util.exist_file(filepath):
            QTUtil2.message_error(self, "%s\n%s" % (_("This database already exists."), filepath))
            return

        if self.external_folder:
            file = os.path.join(folder, "%s.lcdblink" % name)
            with open(file, "wt") as q:
                q.write(filepath)
        else:
            file = filepath

        self.dic_data_resp = {
            "ALLOWS_DUPLICATES": self.chb_duplicate.valor(),
            "ALLOWS_POSITIONS": self.chb_positions.valor(),
            "ALLOWS_COMPLETE_GAMES": self.chb_complete.valor(),
            "ALLOWS_ZERO_MOVES": self.chb_zeromoves.valor(),
            "SUMMARY_DEPTH": self.sb_summary.valor(),
        }

        db = DBgames.DBgames(filepath)
        for key, value in self.dic_data_resp.items():
            db.guardaConfig(key, value)
        db.close()

        self.dic_data_resp["FILEPATH"] = file
        self.dic_data_resp["EXTERNAL_FOLDER"] = self.external_folder

        self.accept()
Beispiel #16
0
    def file(self):
        menu = QTVarios.LCMenu(self)
        menu.opcion("saveas", _("Save a copy"), Iconos.GrabarComo())
        menu.separador()
        menu.opcion("restorefrom", _("Restore from"), Iconos.Recuperar())
        menu.separador()
        submenu = menu.submenu(_("Create new"), Iconos.Nuevo())
        submenu.opcion("new_UNED", _("UNED chess school"), Iconos.Uned())
        submenu.separador()
        submenu.opcion("new_UWE", _("Uwe Auerswald"), Iconos.Uwe())
        submenu.separador()
        submenu.opcion("new_SM", _("Singular moves"), Iconos.Singular())
        menu.separador()
        submenu = menu.submenu(_("Export to"), Iconos.DatabaseMas())
        submenu.opcion("save_pgn", _("A PGN file"), Iconos.FichPGN())
        submenu.separador()
        submenu.opcion("save_db", _("Database"), Iconos.Database())

        resp = menu.lanza()
        if resp is None:
            return
        if resp == "saveas":
            liGen = [(None, None)]
            config = FormLayout.Editbox(_("Name"), ancho=160)
            liGen.append((config, ""))

            resultado = FormLayout.fedit(liGen,
                                         title=_("Name"),
                                         parent=self,
                                         icon=Iconos.GrabarComo())
            if resultado:
                accion, liResp = resultado
                fich = name = liResp[0]
                if name.lower()[-4:] != ".wsm":
                    fich += ".wsm"
                path = os.path.join(self.configuration.carpeta_results, fich)
                ok = True
                if Util.exist_file(path):
                    ok = QTUtil2.pregunta(
                        self,
                        _X(
                            _("The file %1 already exists, what do you want to do?"
                              ), fich),
                        label_yes=_("Overwrite"),
                        label_no=_("Cancel"),
                    )
                if ok:
                    shutil.copy(self.dbwashing.file, path)
        elif resp == "restorefrom":
            li = []
            for fich in os.listdir(self.configuration.carpeta_results):
                if fich.endswith(".wsm") and fich != self.dbwashing.filename:
                    li.append(fich[:-4])
            if not li:
                QTUtil2.message_bold(self, _("There is no file"))
                return
            menu = QTVarios.LCMenu(self)
            for fich in li:
                menu.opcion(fich, fich, Iconos.PuntoRojo())
            resp = menu.lanza()
            if resp:
                if QTUtil2.pregunta(
                        self, "%s\n%s" %
                    (_("Current data will be removed and overwritten."),
                     _("Are you sure?"))):
                    shutil.copy(
                        os.path.join(self.configuration.carpeta_results,
                                     resp + ".wsm"), self.dbwashing.file)
                    self.wreload = True
                    self.save_video()
                    self.accept()
        elif resp.startswith("new_"):
            tactic = resp[4:]
            if QTUtil2.pregunta(
                    self, "%s\n%s" %
                (_("Current data will be removed and overwritten."),
                 _("Are you sure?"))):
                self.dbwashing.new(tactic)
                self.wreload = True
                self.save_video()
                self.accept()

        elif resp.startswith("save_"):

            def other_pc():
                for engine in self.washing.liEngines:
                    if engine.state == Washing.ENDED:
                        game = self.dbwashing.restoreGame(engine)
                        pc = Game.Game()
                        pc.assign_other_game(game)
                        dt = engine.date if engine.date else Util.today()
                        if engine.color:
                            white = self.configuration.x_player
                            black = engine.name
                            result = "1-0"
                            whiteelo = str(self.configuration.x_elo)
                            blackelo = engine.elo
                        else:
                            black = self.configuration.x_player
                            white = engine.name
                            result = "0-1"
                            blackelo = str(self.configuration.x_elo)
                            whiteelo = engine.elo
                        tags = [
                            ["Site", "Lucas Chess"],
                            ["Event", _("The Washing Machine")],
                            ["Date",
                             "%d-%d-%d" % (dt.year, dt.month, dt.day)],
                            ["White", white],
                            ["Black", black],
                            ["WhiteElo", whiteelo],
                            ["BlackElo", blackelo],
                            ["Result", result],
                        ]
                        ap = game.opening
                        if ap:
                            tags.append(["ECO", ap.eco])
                            tags.append(["Opening", ap.trNombre])
                        pc.set_tags(tags)
                        yield pc

            if resp == "save_db":
                ext = "lcg"
                path = QTUtil2.salvaFichero(
                    self,
                    _("Database of complete games"),
                    self.configuration.ficheroDBgames,
                    _("File") + " %s (*.%s)" % (ext, ext),
                    False,
                )
                if path:
                    if not path.lower().endswith(".lcdb"):
                        path += ".lcdb"
                    me = QTUtil2.mensEspera.start(self, _("Saving..."))
                    dbn = DBgames.DBgames(path)
                    for pc in other_pc():
                        dbn.insert(pc)
                    me.final()
                    QTUtil2.message_bold(self, _X(_("Saved to %1"), path))
            else:
                w = WindowSavePGN.WSaveVarios(self, self.configuration)
                if w.exec_():
                    ws = WindowSavePGN.FileSavePGN(self, w.dic_result)
                    if ws.open():
                        ws.um()
                        for n, pc in enumerate(other_pc()):
                            if n or not ws.is_new:
                                ws.write("\n\n")
                        ws.write(pc.pgn())
                    ws.close()
                    ws.um_final()
Beispiel #17
0
    def phase2(self, pb: QTUtil2.BarraProgreso1, entry: os.DirEntry):
        dest = entry.name

        name = ".".join(entry.name.split(".")[:-2])
        pb.ponRotulo(name)

        li = dest.split(".")
        dest = ".".join(li[:-2])
        path_dest = os.path.join(Code.configuration.folder_databases(),
                                 dest + ".lcdb")
        db_dest = DBgames.DBgames(path_dest)
        db_ori = LIVersion11(entry.path)
        total = len(db_ori)
        pb.ponTotal(total)
        for x in range(total):
            pb.pon(x + 1)
            if pb.is_canceled():
                break
            dic = db_ori[x]
            g = Game.Game(fen=dic.get("INIFEN"))
            g.set_tags(dic["LITAGS"])
            result = g.get_tag("Result")
            g.set_termination(dic["TERMINATION"],
                              result if result else RESULT_UNKNOWN)
            li_moves = dic["MOVES"]
            current_position = g.last_position.copia()
            for dic_mv in li_moves:
                pv = dic_mv["M"]
                position = current_position.copia()
                position.moverPV(pv)
                move = Move.Move(g,
                                 position_before=current_position,
                                 position=position,
                                 from_sq=pv[:2],
                                 to_sq=pv[2:4],
                                 promotion=pv[4:])
                if "VARIATIONS" in dic_mv:
                    li_varpgn = dic_mv["VARIATIONS"]
                    fen_base = current_position.fen()
                    for varpgn in li_varpgn:
                        gv = Game.fen_game(fen_base, varpgn)
                        if gv:
                            move.add_variation(gv)
                if "COMMENT" in dic_mv:
                    move.comment = dic_mv["COMMENT"]
                if "$NAGS" in dic_mv:
                    nags = dic_mv["$NAGS"]
                    for nag in nags.split(" "):
                        if nag.isdigit():
                            move.add_nag(int(nag))
                if "NAGS" in dic_mv:
                    nags = dic_mv["NAGS"]
                    for nag in nags.split(" "):
                        if nag in self.dic_cnags:
                            move.add_nag(self.dic_cnags[nag])
                if "AMRM" in dic_mv:
                    mrm_pos = dic_mv["APOS"]
                    mrm_save = dic_mv["AMRM"]
                    mrm = EngineResponse.MultiEngineResponse(None, True)
                    mrm.restore(mrm_save)
                    move.analysis = mrm, mrm_pos

                current_position = position.copia()
                g.add_move(move)

            db_dest.insert(g)
        db_ori.close()
        if pb.is_canceled():
            db_dest.close()
            return False

        db_dest.commit()
        db_dest.close()

        shutil.move(entry.path, entry.path + ".imported")
        return True