예제 #1
0
    def __init__(self, procesador, path_bloque):

        QTVarios.WDialogo.__init__(
            self, procesador.main_window, _("The board at a glance"), Iconos.Gafas(), "visualizaBase"
        )

        self.procesador = procesador
        self.configuracion = procesador.configuracion

        self.path_bloque = path_bloque

        fichero = os.path.join(self.configuracion.carpeta_results, os.path.basename(path_bloque) + "db")
        self.historico = UtilSQL.DictSQL(fichero)
        self.li_histo = self.calcListaHistorico()

        # Historico
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("SITE", _("Site"), 100, centered=True)
        o_columns.nueva("DATE", _("Date"), 100, centered=True)
        o_columns.nueva("LEVEL", _("Level"), 80, centered=True)
        o_columns.nueva("TIME", _("Time used"), 80, centered=True)
        o_columns.nueva("ERRORS", _("Errors"), 80, centered=True)
        o_columns.nueva("INTERVAL", _("Interval"), 100, centered=True)
        o_columns.nueva("POSITION", _("Position"), 80, centered=True)
        o_columns.nueva("COLOR", _("Square color"), 80, centered=True)
        o_columns.nueva("ISATTACKED", _("Is attacked?"), 80, centered=True)
        o_columns.nueva("ISATTACKING", _("Is attacking?"), 80, centered=True)
        self.ghistorico = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True)
        self.ghistorico.setMinimumWidth(self.ghistorico.anchoColumnas() + 20)

        # Tool bar
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Play"), Iconos.Empezar(), self.play),
            None,
            (_("New"), Iconos.Nuevo(), self.new),
            None,
            (_("Remove"), Iconos.Borrar(), self.remove),
            None,
        )
        self.tb = Controles.TBrutina(self, li_acciones)

        # Colocamos
        ly = Colocacion.V().control(self.tb).control(self.ghistorico).margen(3)

        self.setLayout(ly)

        self.register_grid(self.ghistorico)
        self.restore_video()
        self.ghistorico.gotop()
예제 #2
0
    def __init__(self, procesador, tipo):
        # Variables
        self.configuration = procesador.configuration
        self.tipo = tipo

        self.fichDB = self.configuration.ficheroBoxing + tipo
        self.db = UtilSQL.DictSQL(self.fichDB)
        self.conf = self.db["CONFIG"]
        if self.conf is None:
            self.conf = {"SEGUNDOS": 5, "PUNTOS": 100, "NIVELHECHO": 0, "MAXERROR": 0}

        self.liMotores = self.configuration.comboMotores()  # name, key
        self.claveActual = self.calcClaveActual()
        self.dicActual = self.dameDicActual()
    def __init__(self, procesador):

        QTVarios.WDialogo.__init__(self, procesador.main_window,
                                   _("Your daily test"), Iconos.DailyTest(),
                                   "nivelBase")

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

        self.historico = UtilSQL.DictSQL(self.configuration.ficheroDailyTest)
        self.calcListaHistorico()

        self.engine, self.segundos, self.pruebas, self.fns = self.leeParametros(
        )

        # Historico
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("FECHA", _("Date"), 120, centered=True)
        o_columns.nueva("MPUNTOS", _("Points lost"), 100, centered=True)
        o_columns.nueva("MTIEMPOS", _("Time"), 80, centered=True)
        o_columns.nueva("ENGINE", _("Engine"), 120, centered=True)
        o_columns.nueva("SEGUNDOS", _("Second(s)"), 80, centered=True)
        o_columns.nueva("PRUEBAS", _("N. of tests"), 80, centered=True)
        o_columns.nueva("FNS", _("File"), 150, centered=True)
        self.ghistorico = Grid.Grid(self,
                                    o_columns,
                                    siSelecFilas=True,
                                    siSeleccionMultiple=True)
        self.ghistorico.setMinimumWidth(self.ghistorico.anchoColumnas() + 20)

        # Tool bar
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Start"), Iconos.Empezar(), self.empezar),
            None,
            (_("Configuration"), Iconos.Opciones(), self.configurar),
            None,
            (_("Remove"), Iconos.Borrar(), self.borrar),
            None,
        )
        tb = QTVarios.LCTB(self, li_acciones)

        # Colocamos
        ly = Colocacion.V().control(tb).control(self.ghistorico).margen(3)

        self.setLayout(ly)

        self.register_grid(self.ghistorico)
        self.restore_video()
예제 #4
0
    def finalizar(self):
        self.informacion_activable = True
        self.board.showCoordenadas(True)
        self.main_window.activaJuego(True, False, siAyudas=False)
        self.remove_hints()
        self.main_window.pon_toolbar(
            (TB_CLOSE, TB_REINIT, TB_CONFIG, TB_UTILITIES))
        if self.cancelado:
            self.game = self.game_objetivo
        self.goto_end()
        blancas, negras, fecha, event, result = "", "", "", "", ""
        for key, value in self.game_objetivo.li_tags:
            key = key.upper()
            if key == "WHITE":
                blancas = value
            elif key == "BLACK":
                negras = value
            elif key == "DATE":
                fecha = value
            elif key == "EVENT":
                event = value
            elif key == "RESULT":
                result = value

        self.set_label1(
            "%s - %s<br> %s: <b>%s</b><br>%s: <b>%s</b><br>%s: <b>%s</b>" %
            (fecha, event, _("White"), blancas, _("Black"), negras,
             _("Result"), result))
        numjug = self.jugada_actual
        if numjug > 0:
            self.set_label2(
                '%s: <b>%d</b><br>%s: %0.2f"<br>%s: <b>%d</b><br>%s: <b>%d</b>'
                %
                (_("Moves"), numjug, _("Average time"), self.vtime / numjug,
                 _("Errors"), self.errores, _("Hints"), self.ayudas_recibidas))
            if numjug > 2:
                db = UtilSQL.DictSQL(self.configuration.ficheroAnotar)
                f = Util.today()
                key = "%04d-%02d-%02d %02d:%02d:%02d" % (
                    f.year, f.month, f.day, f.hour, f.minute, f.second)
                db[key] = {
                    "PC": self.game_objetivo.save(),
                    "MOVES": numjug,
                    "TIME": self.vtime / numjug,
                    "HINTS": self.ayudas_recibidas,
                    "ERRORS": self.errores,
                    "COLOR": self.si_blancas_abajo,
                    "TOTAL_MOVES": len(self.game_objetivo),
                }
                db.close()
예제 #5
0
    def import_openingline(self, base_folder, ori_path: str):
        ori_path = os.path.abspath(ori_path)
        ori_folder = os.path.dirname(ori_path)
        subfolder = os.path.relpath(ori_folder, base_folder)
        if subfolder == ".":
            dest_path = os.path.join(Code.configuration.folder_base_openings,
                                     os.path.basename(ori_path))
            op_idx = os.path.join(Code.configuration.folder_base_openings,
                                  "openinglines.pk")
        else:
            dest_path = os.path.join(Code.configuration.folder_base_openings,
                                     subfolder, os.path.basename(ori_path))

            folder_dest = os.path.dirname(dest_path)
            if not Util.create_folder(folder_dest):
                try:
                    os.makedirs(folder_dest)
                except:
                    pass
            op_idx = os.path.join(Code.configuration.folder_base_openings,
                                  subfolder, "openinglines.pk")
        Util.remove_file(op_idx)
        dest_path = Util.filename_unique(dest_path)
        for tabla in ("CONFIG", "FEN", "FENVALUES"):
            db11 = DicSQLV11(ori_path, tabla=tabla)
            if len(db11) > 0:
                db = UtilSQL.DictSQL(dest_path, tabla=tabla)
                li_keys = db11.keys()
                for key in li_keys:
                    try:
                        db[key] = db11[key]
                    except:
                        pass
                db.close()
            db11.close()

        conexion_dest = sqlite3.connect(dest_path)
        conexion_dest.execute(
            "CREATE TABLE IF NOT EXISTS LINES( XPV TEXT PRIMARY KEY );")
        conexion_dest.commit()

        conexion_ori = sqlite3.connect(ori_path)
        cursor_ori = conexion_ori.execute("SELECT XPV FROM LINES")
        for raw in cursor_ori.fetchall():
            conexion_dest.execute("INSERT INTO LINES( XPV ) VALUES( ? )", raw)
        conexion_dest.commit()

        conexion_ori.close()
        conexion_dest.close()
    def configurar(self):
        # Datos
        li_gen = [(None, None)]

        # # Motor
        mt = self.configuration.tutor_inicial if self.engine is None else self.engine

        li_combo = [mt]
        for name, key in self.configuration.comboMotoresMultiPV10():
            li_combo.append((key, name))

        li_gen.append((_("Engine") + ":", li_combo))

        # # Segundos a pensar el tutor
        config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1,
                                    99, 50)
        li_gen.append((config, self.segundos))

        # Pruebas
        config = FormLayout.Spinbox(_("N. of tests"), 1, 40, 40)
        li_gen.append((config, self.pruebas))

        # Fichero
        config = FormLayout.Fichero(_("File"),
                                    "%s (*.fns);;%s PGN (*.pgn)" %
                                    (_("List of FENs"), _("File")),
                                    False,
                                    anchoMinimo=280)
        li_gen.append((config, self.fns))

        # Editamos
        resultado = FormLayout.fedit(li_gen,
                                     title=_("Configuration"),
                                     parent=self,
                                     icon=Iconos.Opciones())
        if resultado:
            accion, li_resp = resultado
            self.engine = li_resp[0]
            self.segundos = li_resp[1]
            self.pruebas = li_resp[2]
            self.fns = li_resp[3]

            param = UtilSQL.DictSQL(self.configuration.ficheroDailyTest,
                                    tabla="parametros")
            param["ENGINE"] = self.engine
            param["SEGUNDOS"] = self.segundos
            param["PRUEBAS"] = self.pruebas
            param["FNS"] = self.fns
            param.close()
예제 #7
0
    def __init__(self, huella_kibitzer):
        configuration = Code.configuration

        fdb = configuration.ficheroTemporal("db")

        self.ipc = UtilSQL.IPC(fdb, True)

        orden = Orden()
        orden.key = KIBRUN_CONFIGURATION
        orden.dv["USER"] = configuration.user
        orden.dv["HUELLA"] = huella_kibitzer

        self.escribe(orden)

        self.popen = XRun.run_lucas("-kibitzer", fdb)
예제 #8
0
    def __init__(self, numkibitzer):
        configuracion = Code.configuracion

        fdb = configuracion.ficheroTemporal("db")

        self.ipc = UtilSQL.IPC(fdb, True)

        orden = Orden()
        orden.key = KIBRUN_CONFIGURACION
        orden.dv["USER"] = configuracion.user
        orden.dv["NUMKIBITZER"] = numkibitzer

        self.escribe(orden)

        self.popen = XRun.run_lucas("-kibitzer", fdb)
예제 #9
0
    def configurar(self):
        # Datos
        li_gen = [(None, None)]

        # # Motor
        mt = self.configuration.tutor_inicial if self.engine is None else self.engine

        li_combo = [mt]
        for name, key in self.configuration.comboMotoresMultiPV10():
            li_combo.append((key, name))

        li_gen.append((_("Engine") + ":", li_combo))

        # # Segundos a pensar el tutor
        config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1,
                                    99, 50)
        li_gen.append((config, self.seconds))

        # Minutos
        config = FormLayout.Spinbox(_("Observation time in minutes"), 0, 99,
                                    50)
        li_gen.append((config, self.min_min))

        config = FormLayout.Spinbox(
            _("Total time (observation + resolution) in minutes"), 0, 99, 50)
        li_gen.append((config, self.min_max))

        # Editamos
        resultado = FormLayout.fedit(li_gen,
                                     title=_("Configuration"),
                                     parent=self,
                                     icon=Iconos.Opciones())
        if resultado:
            accion, liResp = resultado
            self.engine = liResp[0]
            self.seconds = liResp[1]
            self.min_min = liResp[2]
            self.min_max = liResp[3]

            param = UtilSQL.DictSQL(self.configuration.ficheroPotencia,
                                    tabla="parametros")
            param["ENGINE"] = self.engine
            param["SEGUNDOS"] = self.seconds
            param["MIN_MIN"] = self.min_min
            param["MIN_MAX"] = self.min_max
            param.close()
예제 #10
0
 def leeConfBoards(self):
     db = UtilSQL.DictSQL(self.ficheroConfBoards)
     self.dic_conf_boards_pk = db.as_dictionary()
     if not ("BASE" in self.dic_conf_boards_pk):
         with open(Code.path_resource("IntFiles", "basepk.board"),
                   "rb") as f:
             var = pickle.loads(f.read())
             alto = QTUtil.altoEscritorio()
             ancho = QTUtil.anchoEscritorio()
             base = ancho * 950 / 1495
             if alto > base:
                 alto = base
             var["x_anchoPieza"] = int(alto * 8 / 100)
             db["BASE"] = self.dic_conf_boards_pk["BASE"] = var
     # with open("../resources/IntFiles/basepk.board", "wb") as f:
     #      f.write(pickle.dumps(db["BASE"]))
     db.close()
예제 #11
0
    def config_board(self, xid, tamDef, padre="BASE"):
        if xid == "BASE":
            ct = ConfBoards.ConfigBoard(xid, tamDef)
        else:
            ct = ConfBoards.ConfigBoard(xid, tamDef, padre=padre)
            ct.anchoPieza(tamDef)

        if xid in self.dic_conf_boards_pk:
            ct.lee(self.dic_conf_boards_pk[xid])
        else:
            db = UtilSQL.DictSQL(self.ficheroConfBoards)
            self.dic_conf_boards_pk[xid] = db[xid] = ct.graba()
            db.close()

        ct._anchoPiezaDef = tamDef

        return ct
예제 #12
0
    def __init__(self, procesador):

        self.procesador = procesador
        self.configuration = procesador.configuration
        self.resultado = None
        self.db = UtilSQL.DictSQL(self.configuration.ficheroAnotar)
        self.lista = self.db.keys(True, True)
        self.resultado = None

        QTVarios.WDialogo.__init__(self, procesador.main_window,
                                   _("Writing down moves of a game"),
                                   Iconos.Write(), "annotateagame")

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("DATE", _("Date"), 110)
        o_columns.nueva("COLOR", _("Color"), 80, centered=True)
        o_columns.nueva("GAME", _("Game"), 280)
        o_columns.nueva("MOVES", _("Moves"), 80, centered=True)
        o_columns.nueva("TIME", _("Avg time"), 80, centered=True)
        o_columns.nueva("ERRORS", _("Errors"), 80, centered=True)
        o_columns.nueva("HINTS", _("Hints"), 80, centered=True)
        self.glista = Grid.Grid(self,
                                o_columns,
                                siSelecFilas=True,
                                siSeleccionMultiple=True)

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("New"), Iconos.Nuevo(), self.new),
            None,
            (_("Repeat"), Iconos.Copiar(), self.repetir),
            None,
            (_("Remove"), Iconos.Borrar(), self.borrar),
            None,
        )
        tb = Controles.TBrutina(self, li_acciones)

        ly = Colocacion.V().control(tb).control(self.glista).margen(4)

        self.setLayout(ly)

        self.register_grid(self.glista)
        self.restore_video(anchoDefecto=self.glista.anchoColumnas() + 20)
        self.glista.gotop()
예제 #13
0
    def __init__(self, fichdb):
        self.trDic = {
            "mate": _("Mate"),
            "sts": _("STS"),
            "basic": _("Basic"),
            "easy": _("Easy"),
            "medium": _("Medium"),
            "hard": _("Hard")
        }

        SQLBase.DBBase.__init__(self, fichdb)

        self.dicDB = UtilSQL.DictSQL(fichdb, tabla="CONFIG")
        self.tabla = "WORK"

        self.testTabla()

        self.releer()
예제 #14
0
    def __init__(self, procesador):

        self.procesador = procesador

        self.db = UtilSQL.DictSQL(procesador.configuracion.file_sounds(),
                                  "general")
        self.creaListaSonidos()

        titulo = _("Custom sounds")
        icono = Iconos.S_Play()
        extparam = "sounds"
        QTVarios.WDialogo.__init__(self, procesador.main_window, titulo, icono,
                                   extparam)

        # Toolbar
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), "terminar"),
            None,
            (_("Modify"), Iconos.Modificar(), "modificar"),
            None,
            (_("Listen"), Iconos.S_Play(), "play"),
        )
        tb = Controles.TB(self, li_acciones)

        # Lista
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("SONIDO", _("Sound"), 300, centered=True)
        o_columns.nueva("DURACION", _("Duration"), 60, centered=True)

        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True)

        # Layout
        layout = Colocacion.V().control(tb).control(self.grid).margen(3)
        self.setLayout(layout)

        self.grid.gotop()
        self.grid.setFocus()

        self.siPlay = False

        self.register_grid(self.grid)

        if not self.restore_video():
            self.resize(self.grid.anchoColumnas() + 30, 600)
예제 #15
0
    def configurationes(self):
        dbc = UtilSQL.DictSQL(self.configuration.ficheroEntMaquinaConf)
        liConf = dbc.keys(si_ordenados=True)
        menu = Controles.Menu(self)
        SELECCIONA, BORRA, AGREGA = range(3)
        for x in liConf:
            menu.opcion((SELECCIONA, x), x, Iconos.PuntoAzul())
        menu.separador()
        menu.opcion((AGREGA, None), _("Save current configuration"),
                    Iconos.Mas())
        if liConf:
            menu.separador()
            submenu = menu.submenu(_("Remove"), Iconos.Delete())
            for x in liConf:
                submenu.opcion((BORRA, x), x, Iconos.PuntoRojo())
        resp = menu.lanza()

        if resp:
            op, k = resp

            if op == SELECCIONA:
                dic = dbc[k]
                self.restore_dic(dic)
            elif op == BORRA:
                if QTUtil2.pregunta(self, _X(_("Delete %1 ?"), k)):
                    del dbc[k]
            elif op == AGREGA:
                liGen = [(None, None)]

                liGen.append((_("Name") + ":", ""))

                resultado = FormLayout.fedit(liGen,
                                             title=_("Name"),
                                             parent=self,
                                             icon=Iconos.Libre())
                if resultado:
                    accion, liGen = resultado

                    name = liGen[0].strip()
                    if name:
                        dbc[name] = self.save_dic()

        dbc.close()
예제 #16
0
    def __init__(self, file_tournament, file_work):
        QtWidgets.QWidget.__init__(self)

        Code.list_engine_managers = EngineManager.ListEngineManagers()
        self.torneo = TournamentRun(
            file_tournament)  # Tournament.Tournament(file_tournament)
        self.file_work = file_work
        self.db_work = UtilSQL.ListSQL(file_work)

        self.slow_pieces = self.torneo.slow_pieces()

        self.setWindowTitle(
            "%s - %s %d" %
            (self.torneo.name(), _("Worker"), int(file_work[-5:])))
        self.setWindowIcon(Iconos.Torneos())

        # Toolbar
        self.tb = Controles.TBrutina(self, icon_size=24)

        # Board
        conf_board = Code.configuration.config_board("TOURNEYPLAY", 36)
        self.board = Board.Board(self, conf_board)
        self.board.crea()
        Delegados.generaPM(self.board.piezas)

        # PGN
        self.configuration = Code.configuration
        self.game = Game.Game()
        self.pgn = ControlPGN.ControlPGN(self)
        ly_pgn = self.crea_bloque_informacion()

        self.is_closed = False
        self.state = None
        self.current_side = WHITE

        ly_tt = Colocacion.V().control(self.tb).control(self.board)

        layout = Colocacion.H().otro(ly_tt).otro(ly_pgn).relleno().margen(3)
        self.setLayout(layout)

        self.cpu = CPU.CPU(self)

        self.pon_estado(ST_WAITING)
예제 #17
0
    def __init__(self, nom_fichero):
        self.link_file = nom_fichero
        if nom_fichero.endswith(".lcdblink"):
            with open(nom_fichero, "rt", encoding="utf-8",
                      errors="ignore") as f:
                nom_fichero = f.read().strip()
            self.external_folder = os.path.dirname(nom_fichero)
        else:
            self.external_folder = ""
        self.nom_fichero = Util.relative_path(nom_fichero)

        self.conexion = sqlite3.connect(self.nom_fichero)
        self.conexion.row_factory = sqlite3.Row
        self.order = None
        self.filter = None

        self.cache = {}
        self.mincache = 2024
        self.maxcache = 4048

        self.li_fields = self.lista_campos()

        self.allows_duplicates = self.recuperaConfig("ALLOWS_DUPLICATES", True)
        self.allows_positions = self.recuperaConfig("ALLOWS_POSITIONS", True)
        self.allows_complete_game = self.recuperaConfig(
            "ALLOWS_COMPLETE_GAMES", True)
        self.allows_zero_moves = self.recuperaConfig("ALLOWS_ZERO_MOVES", True)

        self.li_order = []

        summary_depth = self.recuperaConfig("SUMMARY_DEPTH", 0)
        self.with_db_stat = summary_depth > 0

        self.db_stat = DBgamesST.TreeSTAT(self.nom_fichero + ".st1",
                                          summary_depth)

        self.li_row_ids = []

        self.rowidReader = UtilSQL.RowidReader(self.nom_fichero, "Games")

        self.with_plycount = "PLYCOUNT" in self.recuperaConfig("dcabs", {})
예제 #18
0
    def __init__(self, nom_fichero):
        self.link_file = nom_fichero
        if nom_fichero.endswith(".lcdblink"):
            with open(nom_fichero, "rt", encoding="utf-8",
                      errors="ignore") as f:
                nom_fichero = f.read().strip()
            self.external_folder = os.path.dirname(nom_fichero)
        else:
            self.external_folder = ""
        self.nom_fichero = Util.relative_path(nom_fichero)

        self.conexion = sqlite3.connect(self.nom_fichero)
        self.conexion.row_factory = sqlite3.Row
        self.order = None
        self.filter = None

        self.cache = {}
        self.mincache = 2024
        self.maxcache = 4048

        self.li_fields = self.lista_campos()

        self.read_options()

        self.li_order = []

        summary_depth = self.read_config("SUMMARY_DEPTH", 0)
        self.with_db_stat = summary_depth > 0

        self.db_stat = DBgamesST.TreeSTAT(self.nom_fichero + ".st1",
                                          summary_depth)

        self.li_row_ids = []

        self.rowidReader = UtilSQL.RowidReader(self.nom_fichero, "Games")

        self.with_plycount = "PLYCOUNT" in self.read_config("dcabs", {})
예제 #19
0
 def set_categorias_rival(self, rival_key, categorias):
     with UtilSQL.DictSQL(self.file_path) as db:
         db[rival_key] = categorias.graba()
예제 #20
0
 def db_config(self):
     return UtilSQL.DictSQL(self.path, tabla="config")
예제 #21
0
 def db(self):
     return UtilSQL.DictSQL(self.path)
예제 #22
0
 def reopen_games(self):
     self.db_engines = UtilSQL.DictObjSQL(self.file, EngineTournament, tabla="engines")
     self.db_games_queued = UtilSQL.ListObjSQL(self.file, GameTournament, tabla="games_queued")
     self.db_games_finished = UtilSQL.ListObjSQL(self.file, GameTournament, tabla="games_finished")
예제 #23
0
 def dbdatos(self):
     return UtilSQL.DictSQL(self.path_db, tabla=self.name)
예제 #24
0
    def menu_run(self, resp):
        if resp:
            if type(resp) == str:
                if resp == "gm":
                    self.entrenaGM()

                elif resp.startswith("mate"):
                    self.jugarMate(int(resp[-1]))

                elif resp == "bmt":
                    self.bmt()

                elif resp.startswith("resistance"):
                    self.resistance(resp[10:])

                elif resp in ["find_all_moves_rival", "find_all_moves_player"]:
                    self.find_all_moves(resp == "find_all_moves_player")

                elif resp == "dailytest":
                    self.dailyTest()

                elif resp == "potencia":
                    self.potencia()

                elif resp == "visualiza":
                    self.visualiza()

                elif resp == "anotar":
                    self.anotar()

                elif resp == "train_book":
                    self.train_book()

                elif resp == "endings_gtb":
                    self.gaviota_endings()

                elif resp.startswith("tactica|"):
                    nada, tipo, name, carpeta, ini = resp.split("|")
                    self.tacticas(tipo, name, carpeta, ini)

                elif resp.startswith("remtactica|"):
                    nada, carpeta, name = resp.split("|")
                    self.tacticaRemove(carpeta, name)

                elif resp.startswith("puente_"):
                    self.puente(int(resp[7:]))

                elif resp.startswith("horses_"):
                    test = int(resp[7])
                    icl, icn, tit = self.horsesDef[test]
                    icon = Code.todasPiezas.icono(icl, icn)
                    self.horses(test, tit, icon)

                elif resp.startswith("ep_"):
                    um = self.procesador.unMomento()
                    entreno = os.path.realpath(resp[3:])
                    titentreno = os.path.basename(entreno)[:-4]
                    # if "/" in entreno:
                    #     dicTraining = TrListas.dicTraining()
                    #     titentreno = ""
                    #     for x in entreno[:-4].split("/")[1:]:
                    #         titentreno += dicTraining.get(x, x) + "/"
                    #     titentreno = titentreno[:-1]
                    with Util.OpenCodec(entreno) as f:
                        todo = f.read().strip()
                    liEntrenamientos = todo.split("\n")
                    nPosiciones = len(liEntrenamientos)
                    um.final()
                    if nPosiciones == 0:
                        return
                    elif nPosiciones == 1:
                        pos = 1
                        jump = False
                    else:
                        db = UtilSQL.DictSQL(
                            self.configuration.ficheroTrainings)
                        data = db[entreno]
                        if type(data) != dict:
                            data = {}
                        posUltimo = data.get("POSULTIMO", 1)
                        jump = data.get("SALTA", False)
                        tipo = data.get("TYPE", "s")
                        resp = WCompetitionWithTutor.numPosicion(
                            self.procesador.main_window, titentreno,
                            nPosiciones, posUltimo, jump, tipo)
                        if resp is None:
                            db.close()
                            return
                        pos, tipo, jump = resp
                        db[entreno] = {
                            "POSULTIMO": pos,
                            "SALTA": jump,
                            "TYPE": tipo
                        }
                        db.close()
                        if tipo.startswith("r"):
                            if tipo == "rk":
                                random.seed(pos)
                            random.shuffle(liEntrenamientos)
                    self.procesador.entrenaPos(pos, nPosiciones, titentreno,
                                               liEntrenamientos, entreno, jump)

                elif resp == "learnPGN":
                    self.learnPGN()

                elif resp == "playGame":
                    self.procesador.play_game()

                elif resp.startswith("map_"):
                    nada, mapa = resp.split("_")
                    self.procesador.trainingMap(mapa)

                elif resp == "transsiberian":
                    self.procesador.showRoute()

                elif resp == "everest":
                    self.everest()

                elif resp.startswith("tol_"):
                    self.turn_on_lights(resp[4:])

                elif resp == "washing_machine":
                    self.washing_machine()

                elif resp == "captures":
                    self.captures()

                elif resp == "counts":
                    self.counts()

                elif resp == "15mate":
                    self.mate15()

                elif resp == "coordinates_blocks":
                    self.coordinates_blocks()

                elif resp == "coordinates_basic":
                    self.coordinates_basic()

            else:
                if resp <= -100:
                    self.menu = None  # ya que puede cambiar y la etiqueta es diferente
                    mem = Memory.Memoria(self.procesador)
                    mem.lanza(abs(resp) - 100)
예제 #25
0
 def set_current_rival_key(self, rival_key):
     with UtilSQL.DictSQL(self.file_path, tabla="config") as db:
         db["CURRENT_RIVAL_KEY"] = rival_key
예제 #26
0
 def guardaConfig(self, key, valor):
     with UtilSQL.DictRawSQL(self.nom_fichero, "Config") as dbconf:
         dbconf[key] = valor
예제 #27
0
def lee_external_engines(configuration):
    file = configuration.file_external_engines()
    db = UtilSQL.DictRawSQL(file)
    dic = db.as_dictionary()
    db.close()
    return dic
예제 #28
0
 def get_db(self, key):
     db = UtilSQL.DictSQL(self.ficheroDB)
     resp = db[key]
     db.close()
     return resp
예제 #29
0
 def recuperaConfig(self, key, default=None):
     with UtilSQL.DictRawSQL(self.nom_fichero, "Config") as dbconf:
         return dbconf.get(key, default)
예제 #30
0
 def put_db(self, key, value):
     db = UtilSQL.DictSQL(self.ficheroDB)
     db[key] = value
     db.close()