From 32ac48643f5760a8f6d912154405786e2cec40d4 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 11 Feb 2017 14:15:19 +0800 Subject: astro/query_ned.py: Add argument "--brief", some updates --- astro/query_ned.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'astro') 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 +# 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: -- cgit v1.2.2