From f33fb4ae6cd20ce2ea48f3a007d391e3cab4711c Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Sat, 7 Dec 2024 08:50:59 +0330 Subject: [PATCH] SqEntryList: rename `filename` to `database` --- pyglossary/glossary_v2.py | 4 ++-- pyglossary/sq_entry_list.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyglossary/glossary_v2.py b/pyglossary/glossary_v2.py index 2cd083c33..b5c1ed42b 100644 --- a/pyglossary/glossary_v2.py +++ b/pyglossary/glossary_v2.py @@ -178,7 +178,7 @@ def _newInMemorySqEntryList(self) -> SqEntryList: return SqEntryList( entryToRaw=self._entryToRaw, entryFromRaw=self._entryFromRaw, - filename="file::memory:", # or "file::memory:?cache=shared" + database="file::memory:", # or "file::memory:?cache=shared" create=True, ) @@ -975,7 +975,7 @@ def _switchToSQLite( self._data = SqEntryList( # pyright: ignore[reportAttributeAccessIssue] entryToRaw=self._entryToRaw, entryFromRaw=self._entryFromRaw, - filename=sq_fpath, + database=sq_fpath, create=True, ) self._cleanupPathList.add(sq_fpath) diff --git a/pyglossary/sq_entry_list.py b/pyglossary/sq_entry_list.py index a27cc2b13..5af505ee6 100644 --- a/pyglossary/sq_entry_list.py +++ b/pyglossary/sq_entry_list.py @@ -41,7 +41,7 @@ def __init__( # noqa: PLR0913 self, entryToRaw: Callable[[EntryType], RawEntryType], entryFromRaw: Callable[[RawEntryType], EntryType], - filename: str, + database: str, create: bool = True, ) -> None: """sqliteSortKey[i] == (name, type, valueFunc).""" @@ -49,13 +49,13 @@ def __init__( # noqa: PLR0913 self._entryToRaw = entryToRaw self._entryFromRaw = entryFromRaw - self._filename = filename + self._database = database - self._con: sqlite3.Connection | None = sqlite3.connect(filename) + self._con: sqlite3.Connection | None = sqlite3.connect(database) self._cur: sqlite3.Cursor | None = self._con.cursor() - if not filename: - raise ValueError(f"invalid {filename=}") + if not database: + raise ValueError(f"invalid {database=}") self._orderBy = "rowid" self._sorted = False