-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.py
52 lines (37 loc) · 1.05 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
#!/usr/bin/env python
import argparse
import logging
import os
import re
import sys
import click
def valid_date(date_string):
DATE_INPUT_FORMAT = '%d-%m-%Y'
from datetime import datetime
try:
return datetime.strptime(date_string, DATE_INPUT_FORMAT)
except ValueError:
msg = "Not a valid date: '{0}'.".format(date_string)
raise argparse.ArgumentTypeError(msg)
@click.group()
def cli():
pass
@cli.group()
def process():
pass
@process.command()
def cbs():
from anyway.parsers.cbs import main
return main()
@process.command()
@click.argument("filename", type=str, default="data/segments/road_segments.xlsx")
def road_segments(filename):
from anyway.parsers.road_segments import parse
return parse(filename)
@process.command()
@click.argument("filename", type=str, default="data/news_flash/news_flash.csv")
def news_flash(filename):
from anyway.parsers.news_flash import parse
return parse(filename)
if __name__ == '__main__':
cli(sys.argv[1:]) # pylint: disable=too-many-function-args