diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-11 14:15:19 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-11 14:15:19 +0800 |
commit | 32ac48643f5760a8f6d912154405786e2cec40d4 (patch) | |
tree | 0e1fe6cd553f47193ceb40603da19e181c03ee7b /astro | |
parent | 66714445d637251e28e2a6283e88a80b838bf91f (diff) | |
download | atoolbox-32ac48643f5760a8f6d912154405786e2cec40d4.tar.bz2 |
astro/query_ned.py: Add argument "--brief", some updates
Diffstat (limited to 'astro')
-rwxr-xr-x | astro/query_ned.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/astro/query_ned.py b/astro/query_ned.py index 959169f..22cb5a8 100755 --- a/astro/query_ned.py +++ b/astro/query_ned.py @@ -1,11 +1,15 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- +# +# Copyright (c) 2016-2017 Weitian LI <liweitianux@live.com> +# MIT license # # References: # [1] astroquery: NedClass # https://astroquery.readthedocs.org/en/latest/api/astroquery.ned.NedClass.html # # Change log: +# 2017-02-11: +# * Add argument "--brief" to not print header # 2016-05-25: # * Also output RA, DEC results # * Update argument process @@ -35,10 +39,6 @@ from astroquery.exceptions import RemoteServiceError # import astropy.units as u -__version__ = "0.2.2" -__date__ = "2016-05-25" - - # Ned configurations Ned.TIMEOUT = 20 @@ -94,12 +94,12 @@ def query_name(name, verbose=False): def main(): parser = argparse.ArgumentParser( description="Query NED database by source name") - parser.add_argument("-V", "--version", action="version", - version="%(prog)s " + "%s (%s)" % (__version__, - __date__)) parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="show verbose information") + parser.add_argument("-b", "--brief", dest="brief", + action="store_true", + help="be brief and do not print header") parser.add_argument("-i", "--input", dest="input", required=True, help="source names to be queried (sep by comma); " + "or a file contains the names (one per line)") @@ -123,7 +123,8 @@ def main(): except TypeError: of = args.output writer = csv.writer(of) - writer.writerow(results_list[0].keys()) + if not args.brief: + writer.writerow(results_list[0].keys()) for res in results_list: writer.writerow(res.values()) if of is not sys.stdout: |