-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·41 lines (33 loc) · 1.05 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
#!/usr/bin/env python3
import click
from datetime import date, timedelta, datetime
from crawlers.officiele_bekendmakingen import Officiele_Bekendmakingen
from crawlers.kb import KB
from config import WEBDAV
from utils import logging
class DateParamType(click.ParamType):
name = 'date'
def convert(self, value, param, ctx):
try:
return datetime.strptime(value, '%Y-%m-%d')
except ValueError:
self.fail('%s is not a valid date' % value, param, ctx)
DATETIME_TYPE = DateParamType()
@click.group()
def cli():
pass
@cli.command()
@click.option('--start-record')
@click.option('--end-record')
def officiele_bekendmakingen(start_record, end_record):
officiele_bekendmakingen = Officiele_Bekendmakingen(WEBDAV)
officiele_bekendmakingen.run(start_record, end_record)
@cli.command()
@click.option('--start_date', type=DATETIME_TYPE)
@click.option('--end_date', type=DATETIME_TYPE)
def kb(start_date, end_date):
kb = KB(WEBDAV)
#kb.run(start_date, end_date)
kb.run()
if __name__ == '__main__':
cli()