B
    b                 @   s|   d Z dZddlZddlZddlZddlZddlZejj	j
Z
dddZdddZddd	Zdadad
d Zdd Zdd ZdS )zSCons.Tool.dvipdf

Tool-specific initialization for dvipdf.

There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.

z,__FILE__ __REVISION__ __DATE__ __DEVELOPER__    Nc             C   s   y|d j j}W n tk
r(   d}Y nX tjj|d|}| |||}|tkrvy|d d= W q tk
rr   Y qX n||d d< |S )zkA builder for DVI files that sets the TEXPICTS environment
       variable before running dvi2ps or dvipdf.r    ZTEXPICTSZENV)	Z
attributespathAttributeErrorSConsScannerLaTeXZmodify_env_var_nullKeyError)ZXXXDviActiontargetsourceenvabspathZ	saved_envresult r   0lib/python3.7/site-packages/SCons/Tool/dvipdf.pyDviPdfPsFunction+   s    
r   c             C   s   t t| ||}|S )N)r   	PDFAction)r
   r   r   r   r   r   r   DviPdfFunctionB   s    r   c             C   s$   | dr|dd| |}nd}|S )zaA strfunction for dvipdf that returns the appropriate
    command string for the no_exec options.Zno_execz
$DVIPDFCOMr   r   )Z	GetOptionZsubst)r
   r   r   r   r   r   r   DviPdfStrFunctionF   s    
r   c                s"   dd   fdd|D }| |fS )zStrips any .aux or .log files from the input source list.
    These are created by the TeX Builder that in all likelihood was
    used to generate the .dvi file we're using as input, and we only
    care about the .dvi file.
    c             S   s   t jt| d dkS )N   )z.auxz.log)r   Utilsplitextstr)nr   r   r   strip_suffixesX   s    z"PDFEmitter.<locals>.strip_suffixesc                s   g | ]} |r|qS r   r   ).0src)r   r   r   
<listcomp>Z   s    zPDFEmitter.<locals>.<listcomp>r   )r
   r   r   r   )r   r   
PDFEmitterR   s    r   c             C   s   t dkrtjdda tdkr.tjjttdaddlm} ||  | d d }|	d	t |
d	t d
| d< tjd| d< d| d< dS )zEAdd Builders and construction variables for dvipdf to an Environment.Nz
$DVIPDFCOMz$DVIPDFCOMSTR)Zstrfunctionr   )pdfZBUILDERSZPDFz.dvidvipdfZDVIPDFr   ZDVIPDFFLAGSzFcd ${TARGET.dir} && $DVIPDF $DVIPDFFLAGS ${SOURCE.file} ${TARGET.file}Z	DVIPDFCOM)r   r   ZActionDVIPDFActionr   r   r   r   generateZ
add_actionZadd_emitterr   r   ZCLVar)r   r   Zbldr   r   r   r"   ]   s    
r"   c             C   s   t jj|  | dS )Nr    )r   ZToolZtexZgenerate_darwinZDetect)r   r   r   r   existsr   s    r#   )NNN)NNN)NNN)__doc__Z__revision__ZSCons.Actionr   ZSCons.DefaultsZSCons.Tool.pdfZSCons.Tool.texZ
SCons.Utilr   r   r   r   r   r   r   r!   r   r"   r#   r   r   r   r   <module>	   s   



	