File: version.py

package info (click to toggle)
python-certbot 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 9,660 kB
  • sloc: python: 44,312; sh: 2,380; makefile: 480
file content (32 lines) | stat: -rwxr-xr-x 930 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
"""Get the current Certbot version number.

Provides a simple utility for determining the Certbot version number

"""
from __future__ import print_function

from os.path import abspath
from os.path import dirname
from os.path import join
import re


def certbot_version(letstest_scripts_dir):
    """Return the version number stamped in certbot/__init__.py."""
    return re.search('''^__version__ = ['"](.+)['"].*''',
                     file_contents(join(dirname(dirname(letstest_scripts_dir)),
                                        'certbot',
                                        'src',
                                        'certbot',
                                        '__init__.py')),
                     re.M).group(1)


def file_contents(path):
    with open(path) as file:
        return file.read()


if __name__ == '__main__':
    print(certbot_version(dirname(abspath(__file__))))