__init__.py 731 Bytes
Newer Older
1
from pkg_resources import get_distribution
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
2

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
3
from .backtranslate import BackTranslate
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
4

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
5

6
7
8
9
10
11
12
13
14
def _get_metadata(name):
    pkg = get_distribution(__package__)

    for line in pkg.get_metadata_lines(pkg.PKG_INFO):
        if line.startswith('{}: '.format(name)):
            return line.split(': ')[1]

    return ''

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
15

16
17
_copyright_notice = 'Copyright (c) {} <{}>'.format(
    _get_metadata('Author'), _get_metadata('Author-email'))
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
18

19
usage = [_get_metadata('Summary'), _copyright_notice]
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
20

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
21

22
def doc_split(func):
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
23
    return func.__doc__.split('\n\n')[0]
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
24

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
25

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
26
def version(name):
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
27
    return '{} version {}\n\n{}\nHomepage: {}'.format(
28
29
        _get_metadata('Name'), _get_metadata('Version'), _copyright_notice,
        _get_metadata('Home-page'))