Coverage for ligo/followup_advocate/tool.py: 100%
39 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-20 11:01 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-20 11:01 +0000
1import argparse
3from ligo.gracedb import rest
5from .. import followup_advocate
8def main(args=None):
9 parser = argparse.ArgumentParser()
10 parser.add_argument(
11 '--version', action='version', version=followup_advocate.__version__)
12 parser.add_argument(
13 '--service', default=rest.DEFAULT_SERVICE_URL, help='GraceDb API URL')
14 parser.add_argument(
15 '--remove_text_wrap', action='store_true',
16 help='Remove text wrapping')
17 subparsers = parser.add_subparsers(help='sub-command help')
19 authors = argparse.ArgumentParser(add_help=False)
20 authors.add_argument(
21 'authors', metavar="'A. Einstein (IAS)'", nargs='*', help='Authors')
23 def add_command(func, **kwargs):
24 subparser = subparsers.add_parser(
25 func.__name__, **dict(kwargs, help=func.__doc__))
26 subparser.set_defaults(func=func)
27 return subparser
29 cmd = add_command(followup_advocate.authors, parents=[authors])
31 cmd = add_command(followup_advocate.compose, parents=[authors])
32 cmd.add_argument(
33 '-m', '--mailto', action='store_true',
34 help='Open new message in default e-mail client [default: false]')
35 cmd.add_argument('gracedb_id', metavar='S123456',
36 help='GraceDB ID of superevent')
38 cmd = add_command(followup_advocate.compose_raven, parents=[authors])
39 cmd.add_argument('gracedb_id', metavar='S123456',
40 help='GraceDB ID of superevent')
42 cmd = add_command(followup_advocate.compose_llama, parents=[authors])
43 cmd.add_argument('gracedb_id', metavar='S123456', help='GraceDB ID')
44 cmd.add_argument('--icecube_alert', metavar='IceCube-230501',
45 required=False,
46 default=None, help='IceCube alert ID')
48 cmd = add_command(followup_advocate.compose_grb_medium_latency,
49 parents=[authors])
50 cmd.add_argument('gracedb_id', metavar='E123456', help='GraceDB ID of GRB')
51 cmd.add_argument('--use_detection_template', action='store_true',
52 help='If given, always use detection template')
53 cmd.add_argument('--use_exclusion_template', dest='use_detection_template',
54 action='store_false',
55 help='If given, always use exclusion template')
56 cmd.set_defaults(use_detection_template=None)
58 cmd = add_command(followup_advocate.compose_update, parents=[authors])
59 cmd.add_argument('gracedb_id', metavar='S123456', help='GraceDB ID')
60 cmd.add_argument('update_types',
61 metavar='sky_localization,em_bright,p_astro,raven',
62 help='List of Update types')
64 cmd = add_command(followup_advocate.compose_retraction, parents=[authors])
65 cmd.add_argument('gracedb_id', metavar='S123456', help='GraceDB ID')
67 cmd = add_command(followup_advocate.compare_skymaps)
68 cmd.add_argument(
69 'paths', nargs='+', metavar='S123456/filename.fits.gz',
70 help='Specify sky maps by GraceDB ID and filename')
72 opts = parser.parse_args(args).__dict__
73 func = opts.pop('func')
74 print(func(**opts))