-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
45 lines (36 loc) · 1.09 KB
/
__init__.py
File metadata and controls
45 lines (36 loc) · 1.09 KB
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
import sys
import json
import singer
from tap_formkeep.client import Client
from tap_formkeep.discover import discover
from tap_formkeep.sync import sync
LOGGER = singer.get_logger()
REQUIRED_CONFIG_KEYS = ['api_token', 'form_ids', 'start_date']
def do_discover(client, config):
"""
Discover and emit the catalog to stdout
"""
LOGGER.info("Starting discover")
catalog = discover(client, config)
json.dump(catalog.to_dict(), sys.stdout, indent=2)
LOGGER.info("Finished discover")
@singer.utils.handle_top_exception(LOGGER)
def main():
"""
Run the tap
"""
parsed_args = singer.utils.parse_args(REQUIRED_CONFIG_KEYS)
state = {}
if parsed_args.state:
state = parsed_args.state
with Client(parsed_args.config) as client:
if parsed_args.discover:
do_discover(client, parsed_args.config)
elif parsed_args.catalog:
sync(
client=client,
config=parsed_args.config,
catalog=parsed_args.catalog,
state=state)
if __name__ == "__main__":
main()