-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathgetversion.py
More file actions
executable file
·45 lines (31 loc) · 879 Bytes
/
getversion.py
File metadata and controls
executable file
·45 lines (31 loc) · 879 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright © 2013-2014 Martin Ueding <mu@martin-ueding.de>
import argparse
import os.path
import re
__docformat__ = "restructuredtext en"
def get_version():
filename = '../CHANGELOG.rst'
pattern = re.compile(r'^v(\d+(?:\.\d+)+)$')
if not os.path.isfile(filename):
filename = os.path.basename(filename)
with open(filename, encoding='utf-8') as f:
for line in f:
m = pattern.match(line)
if m:
return(m.group(1))
return None
def main():
options = _parse_args()
print(get_version())
def _parse_args():
"""
Parses the command line arguments.
:return: Namespace with arguments.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(description="")
return parser.parse_args()
if __name__ == "__main__":
main()