1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config/printprereleasesuffix.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +# Prints the pre-release version suffix based on the version string 1.9 +# 1.10 +# Examples: 1.11 +# 2.1a3 > " 2.1 Alpha 3" 1.12 +# 2.1a3pre > "" 1.13 +# 3.2b4 > " 3.2 Beta 4" 1.14 +# 3.2b4pre > "" 1.15 +from __future__ import print_function 1.16 + 1.17 +import sys 1.18 +import re 1.19 + 1.20 +def get_prerelease_suffix(version): 1.21 + """ Returns the prerelease suffix from the version string argument """ 1.22 + 1.23 + def mfunc(m): 1.24 + return " {0} {1} {2}".format(m.group('prefix'), 1.25 + {'a': 'Alpha', 'b': 'Beta'}[m.group('c')], 1.26 + m.group('suffix')) 1.27 + result, c = re.subn(r'^(?P<prefix>(\d+\.)*\d+)(?P<c>[ab])(?P<suffix>\d+)$', 1.28 + mfunc, version) 1.29 + if c != 1: 1.30 + return '' 1.31 + return result 1.32 + 1.33 +if len(sys.argv) == 2: 1.34 + print(get_prerelease_suffix(sys.argv[1]))