-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsncf_gare.py
52 lines (42 loc) · 1.1 KB
/
sncf_gare.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
import bonobo
import requests
from pyfiles.storages import get_storage
import settings as pyfile_settings
from etl.common import HTTPGet
from etl.opendatasoft import OpendatasoftExtract
from etl.pyfiles import PyfilesLoad
OPENDATASOFT_PORTAL = 'https://data.sncf.com'
DATASET_ID = 'liste-des-gares'
FORMAT = 'csv'
NAMESPACE = 'FR:SNCF'
FILENAME = 'liste-des-gares.csv'
def get_services(**options):
pyfile_storage = get_storage(
pyfile_settings.BACKEND,
pyfile_settings.BACKEND_OPTIONS
)
return {
'pyfile_storage': pyfile_storage,
'http': requests.Session(),
}
def get_graph(**options):
graph = bonobo.Graph(
OpendatasoftExtract(
OPENDATASOFT_PORTAL,
DATASET_ID,
FORMAT
),
HTTPGet(),
PyfilesLoad(
NAMESPACE,
FILENAME,
)
)
return graph
if __name__ == '__main__':
parser = bonobo.get_argument_parser()
with bonobo.parse_args(parser) as options:
bonobo.run(
get_graph(**options),
services=get_services(**options)
)