From da1150d7af3ea6d8de535aff8c196897ca788e2e Mon Sep 17 00:00:00 2001 From: reivilibre <38398653+reivilibre@users.noreply.github.com> Date: Mon, 10 Dec 2018 16:47:48 +0000 Subject: [PATCH] Fixes inability to sync with beta versions of Anki The version string for '2.1.6-beta2' is reported as '2.1.6-' which causes a problem when trying to parse '6-' as an integer. --- ankisyncd/sync_app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ankisyncd/sync_app.py b/ankisyncd/sync_app.py index 3b07420..043d7f7 100644 --- a/ankisyncd/sync_app.py +++ b/ankisyncd/sync_app.py @@ -21,6 +21,7 @@ import json import logging import os import random +import re import string import sys import time @@ -63,7 +64,9 @@ class SyncCollectionHandler(anki.sync.Syncer): version = vs[0] note[name] = int(vs[-1]) - version_int = [int(x) for x in version.split('.')] + # convert the version string, ignoring non-numeric suffixes like in beta versions of Anki + version_nosuffix = re.sub(r'[^0-9.].*$', '', version) + version_int = [int(x) for x in version_nosuffix.split('.')] if client == 'ankidesktop': return version_int < [2, 0, 27]