From 193b09a1a36159101dfb37129b88aa85805c9b28 Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Sat, 7 Dec 2024 08:43:51 +0330 Subject: [PATCH] SqEntryList: remove `persist=` arg, do not cleanup internally --- pyglossary/glossary_v2.py | 2 -- pyglossary/sq_entry_list.py | 13 +------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/pyglossary/glossary_v2.py b/pyglossary/glossary_v2.py index 4ed50f8a7..2cd083c33 100644 --- a/pyglossary/glossary_v2.py +++ b/pyglossary/glossary_v2.py @@ -180,7 +180,6 @@ def _newInMemorySqEntryList(self) -> SqEntryList: entryFromRaw=self._entryFromRaw, filename="file::memory:", # or "file::memory:?cache=shared" create=True, - persist=True, ) def __init__( @@ -978,7 +977,6 @@ def _switchToSQLite( entryFromRaw=self._entryFromRaw, filename=sq_fpath, create=True, - persist=True, ) self._cleanupPathList.add(sq_fpath) diff --git a/pyglossary/sq_entry_list.py b/pyglossary/sq_entry_list.py index 218743db6..1905d3377 100644 --- a/pyglossary/sq_entry_list.py +++ b/pyglossary/sq_entry_list.py @@ -19,8 +19,6 @@ from __future__ import annotations import logging -import os -from os.path import isfile from typing import TYPE_CHECKING from .glossary_utils import Error @@ -45,12 +43,9 @@ def __init__( # noqa: PLR0913 entryFromRaw: Callable[[RawEntryType], EntryType], filename: str, create: bool = True, - persist: bool = False, ) -> None: """ sqliteSortKey[i] == (name, type, valueFunc). - - persist: do not delete the file when variable is deleted """ import sqlite3 @@ -58,7 +53,6 @@ def __init__( # noqa: PLR0913 self._entryFromRaw = entryFromRaw self._filename = filename - self._persist = persist self._con: sqlite3.Connection | None = sqlite3.connect(filename) self._cur: sqlite3.Cursor | None = self._con.cursor() @@ -204,9 +198,4 @@ def close(self) -> None: self._cur = None def __del__(self) -> None: - try: - self.close() - if not self._persist and isfile(self._filename): - os.remove(self._filename) - except AttributeError as e: - log.error(str(e)) + self.close()