Coverage for pesummary/cli/summarygracedb.py: 90.5%
21 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
1#! /usr/bin/env python
3# Licensed under an MIT style license -- see LICENSE.md
5from pesummary.core.cli.parser import ArgumentParser as _ArgumentParser
7__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
10class ArgumentParser(_ArgumentParser):
11 def _pesummary_options(self):
12 options = super(ArgumentParser, self)._pesummary_options()
13 options.update(
14 {
15 "--id": {
16 "required": True,
17 "help": "The GraceDB id of the event you are interested in",
18 },
19 "--info": {
20 "nargs": "+",
21 "help": "Specific information you wish to retrieve",
22 },
23 "--output": {
24 "short": "-o",
25 "help": "Output json file you wish to save the data to",
26 },
27 }
28 )
29 return options
32def main(args=None):
33 """
34 """
35 from pesummary.gw.gracedb import get_gracedb_data
37 _parser = ArgumentParser(description=__doc__)
38 _parser.add_known_options_to_parser(["--id", "--info", "--output"])
39 opts, unknown = _parser.parse_known_args(args=args)
40 data = get_gracedb_data(opts.id, info=opts.info)
41 if opts.output is not None:
42 import json
44 with open(opts.output, "w") as f:
45 json.dump(data, f)
46 return
47 print(data)
50if __name__ == "__main__":
51 main()