tabpy.tabpy   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 26
dl 0
loc 54
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A read_version() 0 14 3
A main() 0 12 2
1
"""
2
TabPy Server.
3
4
Usage:
5
  tabpy [-h] | [--help]
6
  tabpy [--config <CONFIG>] [--disable-auth-warning]
7
8
Options:
9
  -h --help                 Show this screen.
10
  --config <CONFIG>         Path to a config file.
11
  --disable-auth-warning    Disable authentication warning.
12
"""
13
14
import docopt
15
import os
16
from pathlib import Path
17
18
19
def read_version():
20
    ver = "unknown"
21
22
    import tabpy
23
24
    pkg_path = os.path.dirname(tabpy.__file__)
25
    ver_file_path = os.path.join(pkg_path, "VERSION")
26
    if Path(ver_file_path).exists():
27
        with open(ver_file_path) as f:
28
            ver = f.read().strip()
29
    else:
30
        ver = f"Version Unknown, (file {ver_file_path} not found)"
31
32
    return ver
33
34
35
__version__ = read_version()
36
37
38
def main():
39
    args = docopt.docopt(__doc__)
40
    config = args["--config"] or None
41
42
    disable_auth_warning = False
43
    if args["--disable-auth-warning"]:
44
        disable_auth_warning = True
45
46
    from tabpy.tabpy_server.app.app import TabPyApp
47
48
    app = TabPyApp(config, disable_auth_warning)
49
    app.run()
50
51
52
if __name__ == "__main__":
53
    main()
54