1#!/usr/bin/env python3
 2
 3"""Handle GEOEVENTS.
 4
 5Current options:
 6
 7- Parse and display an input geoevents file
 8- Ingest a geoevents file
 9
10Other features that could be placed here:
11
12- Interrogate the GEO_EVENTS table
13- Create geoevents in the EVENTS table
14- Modify GEOEVENTS table and geoevents in EVENTS table
15"""
16
17from chart.common.args import ArgumentParser
18from chart.project import settings
19
20from chartepssg.alg.geoevents_ingester import parse_geoevents
21from chartepssg.alg.geoevents_ingester import ingest_geoevents
22
23
24def main():
25    """Command line entry point."""
26    parser = ArgumentParser()
27    parser.add_argument(
28        "FILE", type=ArgumentParser.input_filename, help="Input filename"
29    )
30    parser.add_argument("--db", metavar="CONN", help="Use database CONN")
31    parser.add_argument(
32        "--ingest",
33        action="store_true",
34        help="Ingest data instead of just displaying it",
35    )
36    args = parser.parse_args()
37    if args.db:
38        settings.set_db_name(args.db)
39
40    if args.FILE:
41        if args.ingest:
42            ingest_geoevents(args.FILE)
43            # ingest_geoevents(parse_geoevents(args.FILE))
44
45        else:
46            for hlch in parse_geoevents(args.FILE):
47                print(hlch)
48
49        parser.exit()
50
51    parser.error("No actions")
52
53
54if __name__ == "__main__":
55    main()