From e1d395daa603f650368251f52bc4d3599133f7a6 Mon Sep 17 00:00:00 2001 From: dayjaby Date: Sat, 10 Sep 2016 15:28:04 +0200 Subject: [PATCH] update skipped versions as well --- ___ankihub.py | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/___ankihub.py b/___ankihub.py index 7945868..519984e 100644 --- a/___ankihub.py +++ b/___ankihub.py @@ -196,12 +196,13 @@ def update(add=[],install=False): } for path,repository in repositories.items(): + username,repositoryName = path.split('/') if repository['update'] != 'never': try: response = urllib2.urlopen("https://api.github.com/repos/{0}/releases/latest".format(path)) - data = response.read() - release = json.loads(data) - datas.append(data) + responseData = response.read() + release = json.loads(responseData) + datas.append(responseData) except Exception as e: datas.append(e) release = {} @@ -209,12 +210,48 @@ def update(add=[],install=False): if release['id'] != repository['id']: data = { 'id': release['id'], - 'name': release['name'], + 'name': repositoryName, 'tag_name': release['tag_name'], - 'body': release['body'], + 'body': '### {0}\n'.format(release['name']) + release['body'], 'assets': map(asset,release['assets']), 'update': 'ask' } + if 'tag_name' in repository: + oldVersion = map(int,repository['tag_name'][1:].split('.')) + while len(oldVersion)<3: + oldVersion.append(0) + else: + oldVersion = [0,0,0] + newVersion = map(int,data['tag_name'][1:].split('.')) + isMinor = len(newVersion)>2 and newVersion[2]>0 + while len(newVersion)<3: + newVersion.append(0) + i = oldVersion[2]+1 + if oldVersion[0]