
    HR-e                     n    d Z ddlZddlmZ ddlmZmZ dgZd Zd Z	d	 Z
d
 Zd Zd Zd Z	 	 	 	 ddZdS )zy
Validates a large collection of web-accessible VOTable files,
and generates a report as a directory tree of HTML files.
    N)get_pkg_data_filename   )htmlresultmake_validation_reportc                  J    t           j                            t                    S )N)ospathdirname__file__     Alib/python3.11/site-packages/astropy/io/votable/validator/main.py
get_srcdirr      s    7??8$$$r   c           	         dd l }g d}t                      }g }|D ]}t          d| d          }|                    |d          5 }|                                D ]}	t          |           |	                                }	|	|vrHt          j        |	|           5 }
||
d<   d d d            n# 1 swxY w Y   |	                    |	           |
                    |	           	 d d d            n# 1 swxY w Y   |S )Nr   )goodbroken	incorrectzdata/urls/cone.z.dat.gzrbrootexpected)gzipsetr   open	readlinesnextstripr   Resultappendadd)destdirsr   typesseenurlstypefilenamefdurlrs              r   get_urlsr,      s   KKK+++E55DD 
 
()H4)H)H)HIIYYx&& 	"||~~  Qiikkd??s999 -Q(,*- - - - - - - - - - - - - - -KK$$$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 Ks7   AC/B,	 C/,B00C/3B04.C//C3	6C3	c                     | \  }}t          j        ||          5 }|                                 d d d            d S # 1 swxY w Y   d S Nr   )r   r   download_xml_contentargsr*   r"   r+   s       r   downloadr2   ,   s    LC	s	)	)	) !Q	   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !   >AAc                     | \  }}t          j        ||          5 }|                                 d d d            d S # 1 swxY w Y   d S r.   )r   r   validate_vor0   s       r   r5   r5   2   s    LC	s	)	)	) Q	                 r3   c                     | \  }}}t          j        ||          5 }|d         |                    |           d d d            d S # 1 swxY w Y   d S )Nr   network_error)r   r   validate_with_votlint)r1   path_to_stilts_jarr*   r"   r+   s        r   votlint_validater:   8   s    '+$W	s	)	)	) 8Q_%##$67778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s   AAAc                     | \  }}t          j        ||          5 }t          j        |           d d d            d S # 1 swxY w Y   d S r.   )r   r   r   write_resultr0   s       r   write_html_resultr=   ?   s    LC	s	)	)	) Q!                 r3   c                 <    | \  }}}t          j        |g|R d|i d S )Ntotal)r   write_index_table)r1   subsetr"   r?   s       r   write_subindexrB   E   s5    !FGU79V999599999r   $astropy.io.votable.validator.resultsTc                     ddl m}m}m} 1t          j                                      st           d          t          j                                      t          j        	                               5 |dd          5 }t          |           ddd           n# 1 swxY w Y   n^d  D               |dd            |           D ]:}t          j        |	          5 }	t          |	d
<   ddd           n# 1 swxY w Y   ;fd D             }
 |dd           |                    t          |
|            |dd           |                    t           |
|           8 |dd           fd D             }|                    t"          ||            |dd           |                    t$          |
|            |dd          5 }t          j         |          }ddd           n# 1 swxY w Y    |dd           t)          j        |             |dd            fd|D             }|                    t,          ||           dS )a  
    Validates a large collection of web-accessible VOTable files.

    Generates a report as a directory tree of HTML files.

    Parameters
    ----------
    urls : list of str, optional
        If provided, is a list of HTTP urls to download VOTable files
        from.  If not provided, a built-in set of ~22,000 urls
        compiled by HEASARC will be used.

    destdir : path-like, optional
        The directory to write the report to.  By default, this is a
        directory called ``'results'`` in the current directory. If the
        directory does not exist, it will be created.

    multiprocess : bool, optional
        If `True` (default), perform validations in parallel using all
        of the cores on this machine.

    stilts : path-like, optional
        To perform validation with ``votlint`` from the the Java-based `STILTS`_
        VOTable parser, in addition to `astropy.io.votable`, set this to the
        path of the ``'stilts.jar'`` file.  ``java`` on the system shell
        path will be used to run it.

    Notes
    -----
    Downloads of each given URL will be performed only once and cached
    locally in *destdir*.  To refresh the cache, remove *destdir*
    first.
    r   )ProgressBarSpinnercolor_printNz does not exist.zLoading URLsgreenc                 `    g | ]+}t          |t                    |                                ,S r   )
isinstancestrencode).0r*   s     r   
<listcomp>z*make_validation_report.<locals>.<listcomp>~   s/    EEE
30D0DE

EEEr   zMarking URLsr   r   c                     g | ]}|fS r   r   )rM   r*   r"   s     r   rN   z*make_validation_report.<locals>.<listcomp>   s    +++sS'N+++r   zDownloading VO files)multiprocesszValidating VO fileszValidating with votlintc                     g | ]}|fS r   r   )rM   xr"   stiltss     r   rN   z*make_validation_report.<locals>.<listcomp>   s     ;;;G,;;;r   zGenerating HTML fileszGrouping resultszGenerating indexzGenerating subindicesc                 4    g | ]}|t                    fS r   )len)rM   rA   r"   r&   s     r   rN   z*make_validation_report.<locals>.<listcomp>   s&    HHHffgs4yy1HHHr   )astropy.utils.consolerE   rF   rG   r	   r
   exists
ValueError
expanduserabspathr,   r   r   r'   mapr2   r5   r:   r=   get_result_subsetsr   write_indexrB   )r&   r"   rP   rS   rE   rF   rG   r#   r*   r+   r1   votlint_argssubsetssubindex_argss   `` `          r   r   r   J   s   N HGGGGGGGGGw~~f%% 	:888999g  ))Ggoog&&G|W^W-- 	(GQ''D	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( FEEEENG,,,;t$$ 	% 	%Cs111 %Q $*% % % % % % % % % % % % % % % ,+++d+++DK&000OOHdO>>>K%w///OOKLOAAA-w777;;;;;d;;;(,\RRRK'111OO%t,OGGG	#W	-	- >+D'1==> > > > > > > > > > > > > > > K"G,,,WdG,,,K'111HHHHHHHHMOONMOMMMMMs6   B**B.1B.1DD	D	#HH
H
)NrC   TN)__doc__r	   astropy.utils.datar    r   r   __all__r   r,   r2   r5   r:   r=   rB   r   r   r   r   <module>re      s     
			 5 4 4 4 4 4        #
$% % %  ,! ! !  8 8 8  : : : 
2	SN SN SN SN SN SNr   