1# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
3
4"""The version and URL for coverage.py"""
5# This file is exec'ed in setup.py, don't import anything!
6
7# Same semantics as sys.version_info.
8version_info = (4, 0, 3, 'final', 0)
9
10
11def _make_version(major, minor, micro, releaselevel, serial):
12    """Create a readable version string from version_info tuple components."""
13    assert releaselevel in ['alpha', 'beta', 'candidate', 'final']
14    version = "%d.%d" % (major, minor)
15    if micro:
16        version += ".%d" % (micro,)
17    if releaselevel != 'final':
18        short = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc'}[releaselevel]
19        version += "%s%d" % (short, serial)
20    return version
21
22
23def _make_url(major, minor, micro, releaselevel, serial):
24    """Make the URL people should start at for this version of coverage.py."""
25    url = "https://coverage.readthedocs.org"
26    if releaselevel != 'final':
27        # For pre-releases, use a version-specific URL.
28        url += "/en/coverage-" + _make_version(major, minor, micro, releaselevel, serial)
29    return url
30
31
32__version__ = _make_version(*version_info)
33__url__ = _make_url(*version_info)
34