Skip to content

Commit

Permalink
SqEntryList: move __iter__ method up
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 6, 2024
1 parent 21fb01e commit 4016dea
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pyglossary/sq_entry_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def append(self, entry: EntryType) -> None:
)
self._len += 1

def __iter__(self) -> Iterator[EntryType]:
if self._cur is None:
raise Error("SQLite cursor is closed")
self._cur.execute(f"SELECT data FROM data ORDER BY {self._orderBy}")
for row in self._cur:
yield self._decode(row[0])

def __iadd__(self, other: Iterable): # -> Self
for item in other:
self.append(item)
Expand Down Expand Up @@ -200,10 +207,3 @@ def __del__(self) -> None:
os.remove(self._filename)
except AttributeError as e:
log.error(str(e))

def __iter__(self) -> Iterator[EntryType]:
if self._cur is None:
raise Error("SQLite cursor is closed")
self._cur.execute(f"SELECT data FROM data ORDER BY {self._orderBy}")
for row in self._cur:
yield self._decode(row[0])

0 comments on commit 4016dea

Please sign in to comment.