This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrwrtrack.py
60 lines (48 loc) · 1.73 KB
/
rwrtrack.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""rwrtrack - a Running with Rifles statistics analysis tool.
Usage:
rwrtrack.py [-q|-v] get [<pages>]
rwrtrack.py [-q|-v] analyse <name> [<dates>]
rwrtrack.py [-q|-v] rank <metric> [<dates>] [--limit=<int>] [--record-filters=<str>] [--diff-filters=<str>]
rwrtrack.py [-q|-v] average [<dates>] [--record-filters=<str>] [--diff-filters=<str>]
rwrtrack.py [-q|-v] sum [<dates>] [--record-filters=<str>] [--diff-filters=<str>]
rwrtrack.py [-q|-v] _dbinfo
rwrtrack.py [-q|-v] _db_migrate_csv
rwrtrack.py [-q|-v] _interact
Options:
-q Quiet mode, reduces logging output to errors and above
-v Verbose output, with full stdout logging
"""
import logging
import logging.config
from pathlib import Path
from docopt import docopt
from rwrtrack.logging import _configure_logging
from commands import _get, _analyse, _average, _rank, _sum, \
_dbinfo, _db_migrate_csv, _interact
logger = logging.getLogger(__name__)
script_dir = Path(__file__).parent
log_conf_path = (script_dir / "logging.conf").resolve()
log_path = (script_dir / "rwrtrackpy.log").resolve()
csv_hist_dir = Path(__file__).parent / Path("csv_historical")
if __name__ == '__main__':
args = docopt(__doc__)
_configure_logging(log_conf_path, log_path, args)
logger.debug(f"docopt output:\n{args}")
if args["get"]:
_get(csv_hist_dir, args)
elif args["analyse"]:
_analyse(args)
elif args["rank"]:
_rank(args)
elif args["average"]:
_average(args)
elif args["sum"]:
_sum(args)
elif args["_dbinfo"]:
_dbinfo()
elif args["_db_migrate_csv"]:
_db_migrate_csv(csv_hist_dir)
elif args["_interact"]:
_interact()
else:
print(__doc__)