mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix add-ons screen showing 'requires Anki >= 2.1.231000'
This commit is contained in:
parent
afa84b5f52
commit
e7436a2b23
3 changed files with 28 additions and 2 deletions
|
@ -323,6 +323,19 @@ def int_version() -> int:
|
|||
return year_num * 10_000 + month_num * 100 + patch_num
|
||||
|
||||
|
||||
def int_version_to_str(ver: int) -> str:
|
||||
if ver <= 99:
|
||||
return f"2.1.{ver}"
|
||||
else:
|
||||
year = ver // 10_000
|
||||
month = (ver // 100) % 100
|
||||
patch = ver % 100
|
||||
out = f"{year:02}.{month:02}"
|
||||
if patch:
|
||||
out += f".{patch}"
|
||||
return out
|
||||
|
||||
|
||||
# these two legacy aliases are provided without deprecation warnings, as add-ons that want to support
|
||||
# old versions could not use the new name without catching cases where it doesn't exist
|
||||
point_version = int_version
|
||||
|
|
10
pylib/tests/test_utils.py
Normal file
10
pylib/tests/test_utils.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
from anki.utils import int_version_to_str
|
||||
|
||||
|
||||
def test_int_version_to_str():
|
||||
assert int_version_to_str(23) == "2.1.23"
|
||||
assert int_version_to_str(230900) == "23.09"
|
||||
assert int_version_to_str(230901) == "23.09.1"
|
|
@ -31,6 +31,7 @@ import aqt.main
|
|||
from anki.collection import AddonInfo
|
||||
from anki.httpclient import HttpClient
|
||||
from anki.lang import without_unicode_isolation
|
||||
from anki.utils import int_version_to_str
|
||||
from aqt import gui_hooks
|
||||
from aqt.qt import *
|
||||
from aqt.utils import (
|
||||
|
@ -825,10 +826,12 @@ class AddonsDialog(QDialog):
|
|||
def compatible_string(self, addon: AddonMeta) -> str:
|
||||
min = addon.min_version
|
||||
if min is not None and min > _current_version:
|
||||
return f"Anki >= 2.1.{min}"
|
||||
ver = int_version_to_str(min)
|
||||
return f"Anki >= {ver}"
|
||||
else:
|
||||
max = abs(addon.max_version)
|
||||
return f"Anki <= 2.1.{max}"
|
||||
ver = int_version_to_str(max)
|
||||
return f"Anki <= {ver}"
|
||||
|
||||
def should_grey(self, addon: AddonMeta) -> bool:
|
||||
return not addon.enabled or not addon.compatible()
|
||||
|
|
Loading…
Reference in a new issue