Example #1
0
 def creaTab(self):
     menu = QTVarios.LCMenu(self)
     menu.opcion("book", _("Polyglot book"), Iconos.Libros())
     menu.separador()
     menu.opcion("dbase", _("Database"), Iconos.Database())
     resp = menu.lanza()
     pos = 0
     if resp == "book":
         book = self.seleccionaLibro()
         if book:
             tabbook = TabBook(self, book, self.configuracion)
             self.liTabs.append((resp, tabbook))
             pos = len(self.liTabs) - 1
             self.tabs.nuevaTab(tabbook, book.nombre, pos)
             self.tabs.setTabIcon(pos, Iconos.Libros())
             self.setPosicion(self.partida, self.njg, pos)
     elif resp == "dbase":
         nomfichgames = QTVarios.selectDB(self, self.configuracion, False,
                                          True)
         if nomfichgames:
             dbSTAT = DBgames.TreeSTAT(nomfichgames + "_s1")
             tabdb = TabDatabase(self, self.procesador, dbSTAT)
             self.liTabs.append((resp, tabdb))
             pos = len(self.liTabs) - 1
             self.setPosicion(self.partida, self.njg, pos)
             nombre = os.path.basename(nomfichgames)[:-4]
             self.tabs.nuevaTab(tabdb, nombre, pos)
             self.tabs.setTabIcon(pos, Iconos.Database())
     self.tabs.activa(pos)
Example #2
0
    def importarSummary(self, ventana, partidabase, ficheroSummary, depth, siWhite, onlyone, minMoves):
        titulo = _("Importing the summary of a database")
        bp = QTUtil2.BarraProgreso1(ventana, titulo)
        bp.ponTotal(0)
        bp.ponRotulo(_X(_("Reading %1"), os.path.basename(ficheroSummary)))
        bp.mostrar()

        dbSTAT = DBgames.TreeSTAT(ficheroSummary)

        if depth == 0:
            depth = 99999

        pvBase = partidabase.pv()
        len_partidabase = len(partidabase)

        liPartidas = []

        def hazPV(lipv_ant):
            if bp.siCancelado():
                return
            n_ant = len(lipv_ant)
            siWhite1 = n_ant % 2 == 0

            pv_ant = " ".join(lipv_ant) if n_ant else ""
            liChildren = dbSTAT.children(pv_ant, False)

            if len(liChildren) == 0 or len(lipv_ant) > depth:
                p = Partida.Partida()
                p.leerLIPV(lipv_ant)
                if len(p) > len_partidabase:
                    liPartidas.append(p)
                    bp.ponTotal(len(liPartidas))
                    bp.pon(len(liPartidas))
                return

            if siWhite1 == siWhite:
                tt_max = 0
                limax = []
                for alm in liChildren:
                    tt = alm.W + alm.B + alm.O + alm.D
                    if tt > tt_max:
                        tt_max = tt
                        limax = [alm]
                    elif tt == tt_max and not onlyone:
                        limax.append(alm)
                liChildren = limax

            for alm in liChildren:
                li = lipv_ant[:]
                li.append(alm.move)
                hazPV(li)

        hazPV(pvBase.split(" ") if pvBase else [])

        bp.ponRotulo(_("Writing..."))
        self.guardaPartidas("%s,%s" % (_("Database summary"), os.path.basename(ficheroSummary)), liPartidas)
        bp.cerrar()

        return True