Skip to content

Commit

Permalink
Add some documentation for _lookup_keep_deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
user202729 committed Jan 21, 2024
1 parent a1daaa3 commit 3b4d56d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plover/steno_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ def set_dicts(self, dicts):
self.dicts = dicts[:]

def _lookup_keep_deleted(self, key, dicts=None, filters=()):
"""
Lookup a key in the given dicts.
If key appears in none of the dicts, return None.
If key appears in some dicts but with "{plover:deleted}" as value,
return "{plover:deleted}".
"""
if dicts is None:
dicts = self.dicts
key_len = len(key)
Expand All @@ -195,6 +201,11 @@ def _lookup_keep_deleted(self, key, dicts=None, filters=()):
return value

def _lookup(self, key, dicts=None, filters=()):
"""
Same as _lookup_keep_deleted, but if key appears in some dicts
but with "{plover:deleted}" as value (case-insensitive),
return None instead.
"""
result = self._lookup_keep_deleted(key, dicts, filters)
if result is None or result.lower() == "{plover:deleted}":
return None
Expand All @@ -203,7 +214,8 @@ def _lookup(self, key, dicts=None, filters=()):
def _lookup_from_all(self, key, dicts=None, filters=()):
''' Key lookup from all dictionaries
Returns list of (value, dictionary) tuples
Returns list of (value, dictionary) tuples.
Entries with value "{plover:deleted}" are kept.
'''
if dicts is None:
dicts = self.dicts
Expand Down

0 comments on commit 3b4d56d

Please sign in to comment.