calendar/providers/gdata/makeversion.py
author tbirdbld
Mon, 14 Nov 2016 03:02:33 -0800
changeset 26104 e95d9bd956af9a8e8506d857af298d14ef1e36fc
parent 21485 a24a537854677134bc91c81498e50f1524e7dc66
permissions -rw-r--r--
No bug, Automated blocklist update from host bld-linux64-spot-340 - a=blocklist-update

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import sys
import re

# Converts a Lightning version to a matching gdata version:
#  Lightning 3.1 -> gdata-provider 1.0
#  Lightning 3.2b2 -> gdata-provider 1.1b2
#  Lightning 3.3a1 -> gdata-provider 1.2a1
def makeversion(x):
    v = re.search(r"(\d+\.\d+)([a-z]\d+)?", x)
    parts = v.group(1).split('.')
    major = int(parts[0]) - 2
    minor = int(parts[1]) - 1
    if minor < 0:
        minor = 10 + minor
        major = major - 1
    parts[0] = str(major)
    parts[1] = str(minor)
    return '.'.join(parts) + (v.group(2) or "")

if __name__ == '__main__':
    print(makeversion(sys.argv[1]))