def fichero(self, siNuestro=False, siBuscar=False, path=""): if path: if not os.path.isfile(path): return self.siFicheroNuestro = siNuestro if siNuestro: path = self.nuestroFichero elif siBuscar: # Elegimos el fichero files = QTVarios.select_pgns(self.pantalla) if not files: if self.muestraInicial: self.finPartida() return if len(files) == 1: path = files[0] else: path = self.configuracion.ficheroTemporal("pgn") with open(path, "wb") as q: for fich in files: with open(fich, "rb") as f: q.write(f.read()) # ~ else ya esta el nombre fpgn = PGN.PGN() dicDB = fpgn.leeFichero(self.pantalla, path) if dicDB is None: return None self.ficheroMostrar(dicDB, False)
def import_pgn(self): li_path_pgn = QTVarios.select_pgns(self.wpolyglot) if not li_path_pgn: return titulo = "%s %d %s" % (_("Import"), len(li_path_pgn), _("PGN")) 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() for path_pgn in li_path_pgn: 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_pgn)) dltmp.show() ok = self.add_pgn(path_pgn, plies, st_results, st_side, ru.encode(), time.time, 1.2, dltmp.dispatch, fsum) dltmp.close() if not ok: db.close() return self.merge(db, min_games, min_score, calc_weight, save_score, collisions)
def tg_importar_PGN(self): files = QTVarios.select_pgns(self) if not files: return None dlTmp = QTVarios.ImportarFicheroPGN(self) dlTmp.show() self.dbGames.leerPGNs(files, dlTmp) self.actualiza(True) self.wsummary.reset()
def import_pgn(self): li_path_pgn = QTVarios.select_pgns(self) if not li_path_pgn: return um = QTUtil2.unMomento(self, _("Working...")) li_fens = [] for path_pgn in li_path_pgn: with FasterCode.PGNreader(path_pgn, 1) as fpgn: for (body, raw, pv, liFens, bdCab, bdCablwr, btell) in fpgn: if b"FEN" in bdCab: fen = bdCab[b"FEN"].decode() li_fens.append(fen) self.import_lifens("pgn", li_fens, um)
def tw_importar_PGN(self): files = QTVarios.select_pgns(self) if not files: return None dlTmp = QTVarios.ImportarFicheroPGN(self) if self.dbGames.allows_duplicates: dlTmp.hide_duplicates() dlTmp.show() self.dbGames.leerPGNs(files, dlTmp) self.rehaz_columnas() self.actualiza(True) if self.wsummary: self.wsummary.reset()