Skip to content
This repository was archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #12 from AlexRiina/anki-2.1.22-compat
Browse files Browse the repository at this point in the history
Anki 2.1.22 compat
  • Loading branch information
AlexRiina authored Dec 31, 2020
2 parents 5fe6748 + 1b8f826 commit 3c0a710
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ The manual testing checklist is:
- `("Basic front 1", "1")`
- `("Basic front 2", "2")`
- `("3", "3")`
1. add a rule to suppress Basic cards when rehearsing a Basic card when the Front side is the same
1. review deck and confirm that the rehearsing suppresses card
1. add a rule to suppress Basic cards when rehearsing a Basic card when the Front side is the similar (threshold 0.80)
1. review deck and confirm that the rehearsing suppresses card
17 changes: 13 additions & 4 deletions src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,21 @@ def __init__(self, col):
self.col = col

def load(self) -> List[MatchRule]:
return [
self._deserialize_rule(row) for row in self.col.get_config(self.key, [])
]
try:
config = self.col.get_config(self.key, [])
except AttributeError:
# Compatibility with Anki<2.1.24
config = self.col.conf.get(self.key, [])
return [self._deserialize_rule(row) for row in config]

def save(self, match_rules: Iterable[MatchRule]):
self.col.set_config(
try:
set_config = self.col.set_config()
except AttributeError:
# Compatibility with Anki<2.1.24
set_config = self.col.conf.__setitem__

set_config(
self.key,
sorted(
[
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[tox]
# earlier version of anki are not available on pypi
envlist = {py38}-{anki212}
envlist = {py38}-{anki_2125, anki_2135, anki_latest}

[testenv]
deps =
mypy
PyQT5-stubs
anki212: anki >= 2.1.20, < 2.1.30
anki_2125: anki == 2.1.25
anki_2135: anki == 2.1.35
anki_latest: anki >= 2.1.38

commands =
mypy src

0 comments on commit 3c0a710

Please sign in to comment.