ó
›ßÈ[c           @` s’   d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l	 m
 Z
 d g Z e
 d	 d
 d ƒd e f d „  ƒ  Yƒ Z d „  Z d S(   u5   Inspect results from `astropy.vo.validator.validate`.i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   get_remote_catalog_dbi   (   t
   deprecatedu   ConeSearchResultsu   2.0t   alternativeu<   astroquery.vo_conesearch.validator.inspect.ConeSearchResultst   ConeSearchResultsc           B` sD   e  Z d  Z e e d „ Z d d „ Z d e d „ Z d d „ Z	 RS(   u  A class to store Cone Search validation results.

    Attributes
    ----------
    dbtypes : list
        Cone Search database identifiers.

    dbs : dict
        Stores `~astropy.vo.client.vos_catalog.VOSDatabase`
        for each ``dbtypes``.

    catkeys : dict
        Stores sorted catalog keys for each ``dbtypes``.

    Parameters
    ----------
    cache : bool
       Read from cache, if available.
       Default is `False` to ensure the latest data are read.

    verbose : bool
        Show download progress bars.

    c         C` s|   d d d d g |  _  i  |  _ i  |  _ xN |  j  D]C } t d | d | d | ƒ|  j | <|  j | j ƒ  |  j | <q1 Wd  S(   Nu   goodu   warnu	   exceptionu   erroru   conesearch_t   cachet   verbose(   t   dbtypest   dbst   catkeysR   t   list_catalogs(   t   selfR   R	   t   typ(    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyt   __init__+   s    		 c         C` s³   | d k r t j } n  g  } d } xG |  j D]< } t |  j | ƒ } | | 7} | j d j | | ƒ ƒ q. Wt | ƒ d k r¯ | j d j | ƒ ƒ | j d j	 | ƒ ƒ n  d S(   u   
        Tally databases.

        Parameters
        ----------
        fout : output stream
            Default is screen output.

        i    u   {0}: {1} catalog(s)u   total: {0} catalog(s)
u   
N(
   t   Nonet   syst   stdoutR
   t   lenR   t   appendt   formatt   writet   join(   R   t   foutt   str_listt   n_totR   t   n_cur(    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyt   tally5   s    

c   	      C` s‚  | d
 k r t j } n  | |  j k rB t d j |  j ƒ ƒ ‚ n  g  } x|  j | D]ù } |  j | j | ƒ } | r› t	 | d ƒ } t	 | d ƒ } n | d } | d } x# d
 | k rÔ d | | j
 d
 ƒ <q² W| | | d g 7} t | ƒ d k r| j d j | ƒ ƒ n  t | ƒ d k r?| j d j | ƒ ƒ n  | d	 c d 7<qV Wt | ƒ d k r~| j d j | ƒ ƒ n  d
 S(   u:  
        List catalogs in given database.

        Listing contains:

            #. Catalog key
            #. Cone search access URL
            #. Warning codes
            #. Warning descriptions

        Parameters
        ----------
        typ : str
            Any value in ``self.dbtypes``.

        fout : output stream
            Default is screen output.

        ignore_noncrit : bool
            Exclude warnings in
            `astropy.vo.validator.Conf.noncritical_warnings`.  This is
            useful to see why a catalog failed validation.

        u   'typ' is not one of {}u   validate_warning_typesu   validate_warningsu   Noneu   urli    u   ,u   
iÿÿÿÿN(   R   R   R   R
   t
   ValueErrorR   R   R   t   get_catalogt   _exclude_noncritt   indexR   R   R   R   (	   R   R   R   t   ignore_noncritR   t   catt   cat_dbt   out_wtt   out_ws(    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyt	   list_catsN   s,    

c         C` s«   | d k r t j } n  g  } xW |  j D]L } | |  j | k r( | |  j | j | ƒ j ƒ  d j | ƒ g 7} Pq( q( Wt	 | ƒ d k r§ | j
 d j | ƒ d ƒ n  d S(   uÿ   
        Display a single catalog of given key.

        If not found, nothing is written out.

        Parameters
        -----------
        key : str
            Catalog key.

        fout : output stream
            Default is screen output.

        u   
Found in {0}i    u   
N(   R   R   R   R
   R   R   R   t   dumpsR   R   R   R   (   R   t   keyR   R   R   (    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyt	   print_catˆ   s    N(
   t   __name__t
   __module__t   __doc__t   Falset   TrueR   R   R   R'   R*   (    (    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyR      s
   
:c         C` sƒ   d d l  m } g  } xf |  D]^ } d } | d k	 r_ x' | j D] } | | j | ƒ 7} q? Wn  | d k r | j | ƒ q q W| S(   u  
    Exclude any items in input list containing
    `astropy.vo.validator.Conf.noncritical_warnings`.

    Parameters
    ----------
    in_list : list
        List of strings to process.

    Returns
    -------
    out_list : list
        List with only qualified strings.

    i   (   t   confi    N(   t    R0   R   t   noncritical_warningst   countR   (   t   in_listR0   t   out_listt   st   nt   w(    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyR    ¨   s    (   R-   t
   __future__R    R   R   R   R   t   client.vos_catalogR   t   utils.decoratorsR   t   __all__t   objectR   R    (    (    (    s;   lib/python2.7/site-packages/astropy/vo/validator/inspect.pyt   <module>   s   "		–