def init_tag_database(self, importer=None): """ Create/open .sqlite database of game header tags """ # Import .pgn header tags to .sqlite database sqlite_path = self.path.replace(".pgn", ".sqlite") if os.path.isfile( self.path) and os.path.isfile(sqlite_path) and getmtime( self.path) > getmtime(sqlite_path): metadata.drop_all(self.engine) metadata.create_all(self.engine) ini_schema_version(self.engine) size = self.size if size > 0 and self.tag_database.count == 0: if size > 10000000: drop_indexes(self.engine) if self.progressbar is not None: from gi.repository import GLib GLib.idle_add(self.progressbar.set_text, _("Importing game headers...")) if importer is None: importer = PgnImport(self) importer.initialize() importer.do_import(self.path, progressbar=self.progressbar) if size > 10000000 and not importer.cancel: create_indexes(self.engine) return importer
def init_tag_database(self, importer=None): """ Create/open .sqlite database of game header tags """ # Import .pgn header tags to .sqlite database sqlite_path = self.path.replace(".pgn", ".sqlite") if os.path.isfile(self.path) and os.path.isfile(sqlite_path) and getmtime(self.path) > getmtime(sqlite_path): metadata.drop_all(self.engine) metadata.create_all(self.engine) ini_schema_version(self.engine) size = self.size if size > 0 and self.tag_database.count == 0: if size > 10000000: drop_indexes(self.engine) if self.progressbar is not None: GLib.idle_add(self.progressbar.set_text, _("Importing game headers...")) if importer is None: importer = PgnImport(self) importer.initialize() importer.do_import(self.path, progressbar=self.progressbar) if size > 10000000 and not importer.cancel: create_indexes(self.engine) return importer