Skip to content

Commit

Permalink
Update libaddon
Browse files Browse the repository at this point in the history
  • Loading branch information
glutanimate committed Aug 11, 2019
1 parent 7313ba7 commit ce2e818
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/cloze_overlapper/libaddon/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@

import sys
import os

from aqt import mw
from anki import version
from anki import version as anki_version
from anki.utils import isMac, isWin

__all__ = ["PYTHON3", "ANKI20", "SYS_ENCODING", "MODULE_ADDON",
"MODULE_LIBADDON", "DIRECTORY_ADDONS", "JSPY_BRIDGE",
"PATH_ADDON", "PATH_USERFILES", "PLATFORM"]

PYTHON3 = sys.version_info[0] == 3
ANKI20 = version.startswith("2.0.")
ANKI20 = anki_version.startswith("2.0.")
SYS_ENCODING = sys.getfilesystemencoding()

name_components = __name__.split(".")
Expand All @@ -71,3 +72,24 @@
PLATFORM = "win"
else:
PLATFORM = "lin"

def checkAnkiVersion(lower, upper=None):
"""Check whether anki version is in specified range
By default the upper boundary is set to infinite
Arguments:
lower {str} -- minimum version (inclusive)
Keyword Arguments:
upper {str} -- maximum version (exclusive) (default: {None})
Returns:
bool -- Whether anki version is in specified range
"""
from ._vendor.packaging import version
if upper is not None:
ankiv_parsed = version.parse(anki_version)
return (ankiv_parsed >= version.parse(lower) and
ankiv_parsed < version.parse(upper))
return version.parse(anki_version) >= version.parse(lower)

0 comments on commit ce2e818

Please sign in to comment.