U
    e»{jB  ã                   @   s    d Z ddlZddlZdd„ ZdS )zÖ
Functions to do XML schema and DTD validation.  At the moment, this
makes a subprocess call to xmllint.  This could use a Python-based
library at some point in the future, if something appropriate could be
found.
é    Nc           	      C   s¬   t j |¡\}}|dkrd}n|dkr,d}ntdƒ‚tjddd||| gtjtjd	�}| ¡ \}}|jd
krtt	dƒ‚n,|jdk r ddl
m} t	d ||j ƒ¡ƒ‚|j||fS )ay  
    Validates an XML file against a schema or DTD.

    Parameters
    ----------
    filename : str
        The path to the XML file to validate

    schema_file : str
        The path to the XML schema or DTD

    Returns
    -------
    returncode, stdout, stderr : int, str, str
        Returns the returncode from xmllint and the stdout and stderr
        as strings
    z.xsdz--schemaz.dtdz
--dtdvalidz2schema_file must be a path to an XML Schema or DTDZxmllintz--nooutz--nonet)ÚstdoutÚstderré   z-xmllint not found, so can not validate schemar   )Úsignal_number_to_namez%xmllint was terminated by signal '{}')ÚosÚpathÚsplitextÚ	TypeErrorÚ
subprocessÚPopenÚPIPEÚcommunicateÚ
returncodeÚOSErrorZastropy.utils.miscr   Úformat)	ÚfilenameZschema_fileÚbaseÚextZschema_partÚpr   r   r   © r   úY/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/utils/xml/validate.pyÚvalidate_schema   s,    ý



ÿÿr   )Ú__doc__r   r
   r   r   r   r   r   Ú<module>   s   