def grabar(self): if len(self.dicPtes) == 0: return dic = self.dicPtes self.dicPtes = {} # Creamos una tabla de trabajo dbf = SQLDBF.DBF(self.conexion, self.tablaDatos, "") for k, uno in dic.items(): reg = SQLDBF.Almacen() reg.XPV = uno.xpv() reg.PV = uno.pv() reg.NAG = uno.nag() reg.ADV = uno.adv() reg.COMMENT = uno.comment() reg.POS = uno.pos() reg.FEN = uno.fen() reg.MARK = uno.mark() reg.GRAPHICS = uno.graphics() reg.XDATA = Util.var2blob(uno.xdata()) if uno.rowid() is None: xid = dbf.insertarSoloReg(reg) uno.rowid(xid) else: dbf.modificarROWID(uno.rowid(), reg) dbf.cerrar()
def grabarFichSTAT(self, nomGuide, fich): # Para convertir datos de games a bookGuide self.changeTo(None, nomGuide) f = open(fich, "rb") liRegs = [] for linea in f: linea = linea.strip() xpv, pv, fen = linea.split("|") reg = SQLDBF.Almacen() reg.XPV = xpv reg.PV = pv reg.FEN = fen self.ultPos += 1 reg.POS = self.ultPos liRegs.append(reg) select = "XPV,PV,FEN,POS" dbf = SQLDBF.DBFT(self.conexion, self.tablaDatos, select) def dispatch(num): pass dbf.insertarLista(liRegs, dispatch) dbf.cerrar()
def addMoves(moves, depth, seq): for mv in moves.liMoves: if depth > maxDepth: break seqM1 = seq pv = mv.pv seq += LCEngine.pv2xpv(pv) reg = SQLDBF.Almacen() reg.PV = pv reg.XPV = seq reg.COMMENT = "\n".join(mv.comentarios) reg.FEN = mv.fen reg.NAG = 0 reg.ADV = 0 self.ultPos += 1 reg.POS = self.ultPos for critica in mv.criticas: if critica.isdigit(): t = int(critica) if t in (4, 2, 1, 3, 5, 6): reg.NAG = t elif t in (11, 14, 15, 16, 17, 18, 19): reg.ADV = t else: if critica in dnag: reg.NAG = dnag[critica] liReg.append(reg) if mv.variantes: for variante in mv.variantes: addMoves(variante, depth, seqM1) depth += 1
def hazFEN(fen, ply, seq): plyN = ply + 1 siWhite = " w " in fen siMax = False if whiteBest: siMax = siWhite if blackBest: siMax = siMax or not siWhite liPV = book.miraListaPV(fen, siMax) for pv in liPV: cp.leeFen(fen) cp.mover(pv[:2], pv[2:4], pv[4:]) fenN = cp.fen() reg = SQLDBF.Almacen() lireg.append(reg) reg.PV = pv seqN = seq + LCEngine.pv2xpv(pv) reg.XPV = seqN reg.COMMENT = "" reg.NAG = 0 reg.FEN = fenN reg.ADV = 0 self.ultPos += 1 reg.POS = self.ultPos tmpBP2.ponTotal(1, self.ultPos - basePos) tmpBP2.pon(1, self.ultPos - basePos) if plyN < depth: fenM2 = cp.fenM2() if fenM2 not in stFenM2: stFenM2.add(fenM2) hazFEN(fenN, plyN, seqN)
def generarStandard(self, ventana, siBasic): oLista = AperturasStd.ListaAperturasStd(self.configuracion, True, True) dic = oLista.dic titulo = _("Openings") tmpBP2 = QTUtil2.BarraProgreso2(ventana, titulo) tf = len(dic) tmpBP2.ponTotal(1, tf) tmpBP2.ponRotulo(1, "1. " + _X(_("Reading %1"), titulo)) tmpBP2.ponTotal(2, tf) tmpBP2.ponRotulo(2, "") tmpBP2.mostrar() liRegs = [] dRegs = {} # se guarda una lista con los pv, para determinar el padre for nR, k in enumerate(oLista.dic): tmpBP2.pon(1, nR) tmpBP2.siCancelado() ae = oLista.dic[k] if siBasic and not ae.siBasic: continue liPV = ae.a1h8.split(" ") ult = len(liPV) - 1 seqFather = "" cp = ControlPosicion.ControlPosicion() cp.posInicial() for pos, pv in enumerate(liPV): desde, hasta, coronacion = pv[:2], pv[2:4], pv[4:] seq = seqFather + LCEngine.pv2xpv(pv) cp.mover(desde, hasta, coronacion) if seq not in dRegs: reg = SQLDBF.Almacen() reg.XPV = seq reg.PV = pv reg.FEN = cp.fen() reg.COMMENT = ae.trNombre if pos == ult else "" self.ultPos += 1 reg.POS = self.ultPos liRegs.append(reg) dRegs[seq] = reg seqFather = seq tmpBP2.ponRotulo(2, "2. " + _X(_("Converting %1"), titulo)) tmpBP2.ponTotal(2, len(liRegs)) select = "XPV,PV,COMMENT,FEN,POS" dbf = SQLDBF.DBF(self.conexion, self.tablaDatos, select) def dispatch(num): tmpBP2.pon(2, num) tmpBP2.siCancelado() dbf.insertarLista(liRegs, dispatch) dbf.cerrar() tmpBP2.cerrar()