Skip to content

Commit ef9412f

Browse files
committed
cleanup of comments
1 parent bd34224 commit ef9412f

File tree

3 files changed

+22
-151
lines changed

3 files changed

+22
-151
lines changed

astroquery/nasa_ads/__init__.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
88
"""
99

10-
#~ from astropy.config import ConfigurationItem
11-
1210
from astropy import config as _config
1311

1412

@@ -41,16 +39,10 @@ class Conf(_config.ConfigNamespace):
4139
'/cgi-bin/nph-abs_connect',
4240
'Path for advanced query (unconfirmed)'
4341
)
44-
45-
#~ simple_path = _config.ConfigItem(
46-
#~ '/cgi-bin/nph-basic_connect',
47-
#~ 'Path for simple query'
48-
#~ )
4942
simple_path = _config.ConfigItem(
5043
'/cgi-bin/basic_connect',
5144
'Path for simple query (return XML)'
5245
)
53-
5446
timeout = _config.ConfigItem(
5547
120,
5648
'Time limit for connecting to ADS server'
@@ -68,47 +60,3 @@ class Conf(_config.ConfigNamespace):
6860

6961
__all__ = ['ADSClass', 'ADS',
7062
'Conf', 'conf']
71-
72-
#~ class Conf(_config.ConfigNamespace):
73-
#~ """
74-
#~ Configuration parameters for `astroquery.nasa_ads`.
75-
#~ """
76-
#~ servers = _config.ConfigItem(
77-
#~ ['http://adswww.harvard.edu',
78-
#~ 'http://cdsads.u-strasbg.fr',
79-
#~ 'http://ukads.nottingham.ac.uk',
80-
#~ 'http://esoads.eso.org',
81-
#~ 'http://ads.ari.uni-heidelberg.de',
82-
#~ 'http://ads.inasan.ru',
83-
#~ 'http://ads.mao.kiev.ua',
84-
#~ 'http://ads.astro.puc.cl',
85-
#~ 'http://ads.nao.ac.jp',
86-
#~ 'http://ads.bao.ac.cn',
87-
#~ 'http://ads.iucaa.ernet.in',
88-
#~ 'http://ads.arsip.lipi.go.id',lastpage
89-
#~ 'http://saaoads.chpc.ac.za',
90-
#~ 'http://ads.on.br'],lastpage
91-
#~ 'SAO/NASA ADS mirrors around the world'
92-
#~ )
93-
#~
94-
#~ advanced_url = _config.ConfigurationItem(
95-
#~ '/cgi-bin/nph-abs_connect',
96-
#~ 'Path for advanced query'
97-
#~ )
98-
#~
99-
#~ simple_url = _config.ConfigurationItem(
100-
#~ '/cgi-bin/nph-basic_connect',
101-
#~ 'Path for simple query'
102-
#~ )
103-
#~
104-
#~ timeout = _config.ConfigurationItem(
105-
#~ 60,
106-
#~ 'Time limit for connecting to ADS server'
107-
#~ )
108-
#~
109-
#~ conf = Conf()
110-
#~
111-
#~ from .core import ADS, ADSClass
112-
#~
113-
#~ __all__ = ['ADS', 'ADSClass',
114-
#~ 'Conf', 'conf']

astroquery/nasa_ads/core.py

Lines changed: 18 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,22 @@
77
"""
88

99
import warnings
10-
# example warning
11-
# warnings.warn("Band was specified, so blabla is overridden")
12-
#~ from astropy.io import ascii
13-
#~ from astropy import units as u
1410
from ..query import BaseQuery
1511
from ..utils import commons, async_to_sync
16-
#~ from ..utils.docstr_chompers import prepend_docstr_noreturns
1712
from . import conf
18-
#~ from .utils import *
1913
from astropy.table import Table, Column
2014

2115
from ..utils.class_or_instance import class_or_instance
2216
from ..utils import commons, async_to_sync
2317
from .utils import *
24-
#~ from BeautifulSoup import BeautifulSoup as bfs
2518

2619
from xml.dom import minidom
2720

2821
__all__ = ['ADS', 'ADSClass']
2922

3023
@async_to_sync
3124
class ADSClass(BaseQuery):
32-
33-
####### FROM SPLATALOGUE
25+
3426
SERVER = conf.server
3527
QUERY_ADVANCED_PATH = conf.advanced_path
3628
QUERY_SIMPLE_PATH = conf.simple_path
@@ -39,7 +31,6 @@ class ADSClass(BaseQuery):
3931
QUERY_SIMPLE_URL = SERVER + QUERY_SIMPLE_PATH
4032
QUERY_ADVANCED_URL = SERVER + QUERY_ADVANCED_PATH
4133

42-
######## FROM API DOCS
4334
def __init__(self, *args):
4435
""" set some parameters """
4536
pass
@@ -50,17 +41,14 @@ def query_simple(self, query_string, get_query_payload=False, get_raw_response=F
5041
request_payload = self._args_to_payload(query_string)
5142

5243
response = commons.send_request(self.QUERY_SIMPLE_URL, request_payload, self.TIMEOUT)
53-
44+
5445
# primarily for debug purposes, but also useful if you want to send
5546
# someone a URL linking directly to the data
5647
if get_query_payload:
5748
return request_payload
5849
if get_raw_response:
5950
return response
60-
# parse the XML response into Beautiful Soup
61-
#~ response_bfs = self._parse_response_to_bfs(response)
62-
#
63-
#self._parse_bfs_to_table(response_bfs)
51+
# parse the XML response into AstroPy Table
6452
resulttable = self._parse_response(response.encode(results.encoding).decode('utf-8'))
6553

6654
return resulttable
@@ -73,22 +61,20 @@ def _parse_response(self, response):
7361
hitlist = xmlrepr.childNodes[0].childNodes
7462
hitlist = hitlist[1::2] # every second hit is a "line break"
7563

76-
# Parse the results
77-
# first single items
78-
titles = get_data_from_xml(hitlist, 'title')
79-
bibcode = get_data_from_xml(hitlist, 'bibcode')
80-
journal = get_data_from_xml(hitlist, 'journal')
81-
volume = get_data_from_xml(hitlist, 'volume')
82-
pubdate = get_data_from_xml(hitlist, 'pubdate')
83-
page = get_data_from_xml(hitlist, 'page')
84-
score = get_data_from_xml(hitlist, 'score')
85-
citations = get_data_from_xml(hitlist, 'citations')
86-
abstract = get_data_from_xml(hitlist, 'abstract')
87-
doi = get_data_from_xml(hitlist, 'DOI')
88-
eprintid = get_data_from_xml(hitlist, 'eprintid')
89-
#~ = get_data_from_xml(hitlist, '')
90-
authors = get_data_from_xml(hitlist, 'author')
91-
64+
# Grab the various fields
65+
titles = _get_data_from_xml(hitlist, 'title')
66+
bibcode = _get_data_from_xml(hitlist, 'bibcode')
67+
journal = _get_data_from_xml(hitlist, 'journal')
68+
volume = _get_data_from_xml(hitlist, 'volume')
69+
pubdate = _get_data_from_xml(hitlist, 'pubdate')
70+
page = _get_data_from_xml(hitlist, 'page')
71+
score = _get_data_from_xml(hitlist, 'score')
72+
citations = _get_data_from_xml(hitlist, 'citations')
73+
abstract = _get_data_from_xml(hitlist, 'abstract')
74+
doi = _get_data_from_xml(hitlist, 'DOI')
75+
eprintid = _get_data_from_xml(hitlist, 'eprintid')
76+
authors = _get_data_from_xml(hitlist, 'author')
77+
# put into AstroPy Table
9278
t = Table()
9379
t['title'] = titles
9480
t['bibcode'] = bibcode
@@ -112,69 +98,4 @@ def _args_to_payload(self, query_string):
11298

11399

114100

115-
ADS = ADSClass()
116-
117-
118-
"""
119-
typical fields available:
120-
121-
[u'bibcode',
122-
u'title',
123-
u'author',
124-
u'author',
125-
u'author',
126-
u'affiliation',
127-
u'journal',
128-
u'volume',
129-
u'pubdate',
130-
u'page',
131-
u'keywords',
132-
u'keyword',
133-
u'keyword',
134-
u'keyword',
135-
u'keyword',
136-
u'keyword',
137-
u'origin',
138-
u'link',
139-
u'name',
140-
u'url',
141-
u'link',
142-
u'name',
143-
u'url',
144-
u'link',
145-
u'name',
146-
u'url',
147-
u'link',
148-
u'name',
149-
u'url',
150-
u'link',
151-
u'name',
152-
u'url',
153-
u'count',
154-
u'link',
155-
u'name',
156-
u'url',
157-
u'count',
158-
u'link',
159-
u'name',
160-
u'url',
161-
u'count',
162-
u'link',
163-
u'name',
164-
u'url',
165-
u'link',
166-
u'name',
167-
u'url',
168-
u'count',
169-
u'link',
170-
u'name',
171-
u'url',
172-
u'url',
173-
u'score',
174-
u'citations',
175-
u'abstract',
176-
u'doi',
177-
u'eprintid']
178-
179-
180-
"""
101+
ADS = ADSClass()

astroquery/nasa_ads/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22

3-
def get_data_from_xml(doclist, fieldname, nohitreturn=None):
3+
def _get_data_from_xml(doclist, fieldname, nohitreturn=None):
4+
"""Get the fieldname (i.e. author, title etc)
5+
from minidom.parseString().childNodes[0].childNodes list
6+
"""
47
result = []
58
for element in doclist:
69
fieldlist = element.getElementsByTagName(fieldname)
@@ -10,7 +13,6 @@ def get_data_from_xml(doclist, fieldname, nohitreturn=None):
1013
fields = [nohitreturn]
1114
fields = []
1215
for field in fieldlist: # this is useful for e.g. author field
13-
#~ fields.append(field.childNodes[0].data.decode("utf-8"))
1416
fields.append(field.childNodes[0].data)
1517
result.append(fields)
1618
return result

0 commit comments

Comments
 (0)