-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
70 lines (55 loc) · 2.41 KB
/
main.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
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import argparse
from lss.deviation import deviation
from lss.merge import merge
from lss.splits import Splits
import xml.etree.ElementTree as ET
DEFAULT_COMPARISON = 'GameTime'
def positive_int(value):
ivalue = int(value)
if ivalue <= 0:
raise argparse.ArgumentTypeError('{} is an invalid positive int value'.format(value))
return ivalue
def add_parser_deviation(subparsers):
parser_deviation = subparsers.add_parser('deviation')
parser_deviation.set_defaults(func=deviation)
parser_deviation.add_argument('splits_file',
type=str,
help='The .lss splits file to analyze')
parser_deviation.add_argument('--comparison',
type=str,
help='Time comparison to analyze. Default: {}'.format(DEFAULT_COMPARISON),
default=DEFAULT_COMPARISON,
choices=['GameTime', 'RealTime'])
parser_deviation.add_argument('--minattemptid',
type=int,
help='Minimum attempt id to analyze. Drops data from attempts below this id.')
parser_deviation.add_argument('--zscore-cutoff',
type=positive_int,
help='Z-Score outside of which to drop outliers.')
return parser_deviation
def add_parser_merge(subparsers):
parser_deviation = subparsers.add_parser('merge')
parser_deviation.set_defaults(func=merge)
parser_deviation.add_argument('splits_file',
type=str,
help='The .lss splits file to analyze')
parser_deviation.add_argument('merge_point',
type=str,
help='The the name of the split to remove')
def create_parser():
parser = argparse.ArgumentParser(description='Analyze .lss Splits Files')
subparsers = parser.add_subparsers(dest='command')
subparsers.required = True
add_parser_deviation(subparsers)
add_parser_merge(subparsers)
return parser
def main():
parser = create_parser()
args = parser.parse_args()
tree = ET.parse(args.splits_file)
splits_xml_root = tree.getroot()
splits = Splits(splits_xml_root)
args.func(splits, args)
if __name__ == "__main__":
main()