@@ -126,7 +126,11 @@ def _activate_form(self, response, form_index=0, inputs={}, cache=True,
126126 value = form_elem .select ('option' )[0 ].string
127127
128128 if key in inputs :
129- value = str (inputs [key ])
129+ if isinstance (inputs [key ], list ):
130+ # list input is accepted (for array uploads)
131+ value = inputs [key ]
132+ else :
133+ value = str (inputs [key ])
130134 if (key is not None ):# and (value is not None):
131135 if fmt == 'multipart/form-data' :
132136 if is_file :
@@ -248,16 +252,41 @@ def list_instruments(self, cache=True):
248252 self ._instrument_list .append (u'harps' )
249253 return self ._instrument_list
250254
255+ def list_surveys (self , cache = True ):
256+ """ List all the available surveys (phase 3) in the ESO archive.
257+ Returns
258+ -------
259+ survey_list : list of strings
260+ cache : bool
261+ Cache the response for faster subsequent retrieval
262+ """
263+ if self ._survey_list is None :
264+ survey_list_response = self ._request (
265+ "GET" , "http://archive.eso.org/wdb/wdb/adp/phase3_main/form" ,
266+ cache = cache )
267+ root = BeautifulSoup (survey_list_response .content , 'html5lib' )
268+ self ._survey_list = []
269+ collections_table = root .find ('table' , id = 'collections_table' )
270+ other_collections = root .find ('select' , id = 'collection_name_option' )
271+ for element in (collections_table .findAll ('input' , type = 'checkbox' ) +
272+ other_collections .findAll ('option' )):
273+ if 'value' in element .attrs :
274+ survey = element .attrs ['value' ]
275+ if survey and survey not in self ._survey_list and 'Any' not in survey :
276+ self ._survey_list .append (survey )
277+ return self ._survey_list
278+
251279 def query_surveys (self , surveys = '' , cache = True ,
252280 help = False , open_form = False , ** kwargs ):
253281 """
254282 Query survey Phase 3 data contained in the ESO archive.
255283
256284 Parameters
257285 ----------
258- survey : string
259- Name of the survey to query, one of the names returned by
260- `list_surveys()`.
286+ survey : string or list
287+ Name of the survey(s) to query. Should beone or more of the names
288+ returned by `list_surveys()`. If specified as a string, should be
289+ a comma-separated list of survey names.
261290 cache : bool
262291 Cache the response for faster subsequent retrieval
263292
@@ -281,6 +310,8 @@ def query_surveys(self, surveys='', cache=True,
281310 survey_form = self ._request ("GET" , url , cache = cache )
282311 query_dict = kwargs
283312 query_dict ["wdbo" ] = "csv/download"
313+ if isinstance (surveys , six .string_types ):
314+ surveys = surveys .split ("," )
284315 query_dict ['collection_name' ] = surveys
285316 if self .ROW_LIMIT >= 0 :
286317 query_dict ["max_rows_returned" ] = self .ROW_LIMIT
@@ -301,6 +332,7 @@ def query_surveys(self, surveys='', cache=True,
301332 else :
302333 warnings .warn ("Query returned no results" , NoResultsWarning )
303334
335+
304336 def query_instrument (self , instrument , column_filters = {}, columns = [],
305337 open_form = False , help = False , cache = True , ** kwargs ):
306338 """
0 commit comments