This repository has been archived by the owner on Nov 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage.py
62 lines (46 loc) · 1.59 KB
/
manage.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Vincent Roy & Arthur Claude
"""
import argparse
import sys
from utils import verify_lib
from LoadData import DataLoader
import command
class Manager(object):
def __init__(self):
self.df, self.df_log = (DataLoader())()
parser = argparse.ArgumentParser(
description='Manager of the project',
usage='''manage.py <command>'
The most commonly used commands are:
dataset Access to the dataset
landscape Access to the landscape persistence
norm Access to the norm of the persistence
bottleneck Access to the bottleneck of the persistence
''')
parser.add_argument('command', help='Subcommand to run')
if len(sys.argv) < 2:
print('No command')
parser.print_help()
exit(1)
# parse_args defaults to [1:] for args, but you need to
# exclude the rest of the args too, or validation will fail
args = parser.parse_args(sys.argv[1:2])
if not hasattr(self, args.command):
print('Unrecognized command')
parser.print_help()
exit(1)
# use dispatch pattern to invoke method with same name
getattr(self, args.command)()
def dataset(self):
command.DatasetCommand(self.df, self.df_log)
def landscape(self):
command.LandscapeCommand(self.df, self.df_log)
def norm(self):
command.NormCommand(self.df, self.df_log)
def bottleneck(self):
command.BottleneckCommand(self.df, self.df_log)
if __name__ == '__main__':
Manager()