a
    h|                     @   s@   d dl Z d dlZd dlmZ dddZdd Zedkr<e  dS )	    N)Tempitac                 C   s   t | ddd}| }W d   n1 s,0    Y  t|}| }t |ddd}|| W d   n1 sv0    Y  dS )zProcess tempita templated file and write out the result.

    The template file is expected to end in `.c.tp` or `.pyx.tp`:
    E.g. processing `template.c.in` generates `template.c`.

    rzutf-8)encodingNw)openreadtempitaTemplate
substitutewrite)fromfileoutfilefZtemplate_contenttemplatecontent r   X/var/www/html/assistant/venv/lib/python3.9/site-packages/sklearn/_build_utils/tempita.pyprocess_tempita   s    &
r   c                  C   s   t  } | jdtdd | jddtdd | jddtd	d |  }|jd
s`td|j |jsntdt	j
t	 |j}t	j
|t	j
t	j
|jd d }t|j| d S )NinfilezPath to the input file)typehelpz-oz--outdirzPath to the output directoryz-iz--ignorezKAn ignored input - may be useful to add a dependency between custom targetsz.tpzUnexpected extension: z)Missing `--outdir` argument to tempita.py   r   )argparseArgumentParseradd_argumentstr
parse_argsr   endswith
ValueErrorZoutdirospathjoingetcwdsplitextsplitr   )parserargsZ
outdir_absr   r   r   r   main   s&    	r'   __main__)N)r   r   Cythonr   r   r   r'   __name__r   r   r   r   <module>   s   
