Current File : //usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyo
�
E�`Qc@sdZddgZddlZddlZddlZddlmZiZdZd�Z	d�Z
ejd	�Zejd
�Z
d�Zejd�Zejd
�Zejd�Zejd�Zd�Zejd�Zd�Zd�Zejdej�Zd�Zd�Zd�Zedkr�yejdZWn#ek
rcej Z!ej"Z#n=Xe$ed�Z!ej%j&e�\Z'Z(e'Z)e$e)d�Z#e!j*�Z+yee+�Z,Wn0e-k
r�e�Z.e-dee.f��nXe#j/e,�ndS(sX
takes templated file .xxx.src and produces .xxx file  where .xxx is
.i or .c or .h, using the following template rules

/**begin repeat  -- on a line by itself marks the start of a repeated code
                    segment
/**end repeat**/ -- on a line by itself marks it's end

After the /**begin repeat and before the */, all the named templates are placed
these should all have the same number of replacements

Repeat blocks can be nested, with each nested block labeled with its depth,
i.e.
/**begin repeat1
 *....
 */
/**end repeat1**/

When using nested loops, you can optionally exlude particular
combinations of the variables using (inside the comment portion of the inner loop):

 :exclude: var1=value1, var2=value2, ...

This will exlude the pattern where var1 is value1 and var2 is value2 when
the result is being generated.
  

In the main body each replace will use one entry from the list of named replacements

 Note that all #..# forms in a block must have the same number of
   comma-separated entries.

Example:

    An input file containing

        /**begin repeat
         * #a = 1,2,3#
         * #b = 1,2,3#
         */

        /**begin repeat1
         * #c = ted, jim#
         */
        @a@, @b@, @c@
        /**end repeat1**/

        /**end repeat**/

    produces

        line 1 "template.c.src"

        /*
         *********************************************************************
         **       This file was autogenerated from a template  DO NOT EDIT!!**
         **       Changes should be made to the original source (.src) file **
         *********************************************************************
         */

        #line 9
        1, 1, ted

        #line 9
        1, 1, jim

        #line 9
        2, 2, ted

        #line 9
        2, 2, jim

        #line 9
        3, 3, ted

        #line 9
        3, 3, jim

tprocess_strtprocess_filei����N(t
get_exceptionsE
/*
 *****************************************************************************
 **       This file was autogenerated from a template  DO NOT EDIT!!!!      **
 **       Changes should be made to the original source (.src) file         **
 *****************************************************************************
 */

cCs#|dkrd}d}nd|}d|}d}d}g}x�|j||�}|dkrfPn|jd|�}|jd|�}|j||�}	|jd|	�}
||jd||d	�7}|j||d	|	|
d	|f�||jd|d	|
�7}|
}qD|j�|S(
s�
    The returned line number is from the beginning of the string, starting
    at zero. Returns an empty list if no loops found.

    is/**begin repeats/**end repeat**/s/**begin repeat%ds/**end repeat%d**/i����s*/s
i(tfindtcounttappendtsort(tastrtleveltloopbegtloopendtindtlinetspanlisttstarttstart2tfini1tfini2((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pytparse_structureis,	

$	
cCs8|jd�}|jd�}dj|gt|��S(Niit,(tgrouptjointint(tobjttoreptnumrep((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyt
paren_repl�ss[(]([^)]*)[)]\*(\d+)s([^*]+)\*(\d+)cCs\tjt|�}djg|jd�D]}tjt|j��^q(�}|jd�S(NR(tparenreptsubRRtsplittplainreptstrip(Rtx((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pytparse_values�s	4s\n\s*\*?s#\s*(\w*)\s*=([^#]*)#s(\w*)=(\w*)s	:exclude:cCs�tjd|�}g}tj|�}d}x�|D]}|d}t|d�}t|�}|dkru|}n+||kr�d||f}t|��n|j||f�q4Wg}	xlt	j
|�D][}
|
j�}|jd|d�}||d|!}
t
j|
�}|	jt|��q�Wg}|dkrMtd��nxLt|�D]>}i}x"|D]\}}||||<qmW|j|�qZW|S(s�Find all named replacements in the header

    Returns a list of dictionaries, one for each loop iteration,
    where each key is a name to be substituted and the corresponding
    value is the replacement string.

    Also return a list of exclusions.  The exclusions are dictionaries
     of key value pairs. There can be more than one exclusion.
     [{'var1':'value1', 'var2', 'value2'[,...]}, ...]

    tiis%Mismatch in number of values:
%s = %ss
sNo substitution variables foundN(tstripastRtnamed_retfindalltNoneR!tlent
ValueErrorRt
exclude_retfinditertspanRtexclude_vars_retdicttrange(tloopheadtnamestrepstnsubtreptnametvalstsizetmsgtexcludesRR+tendlinetsubstrtex_namestdlisttittmp((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pytparse_loop_header�s<

	s	@([\w]+)@cs�d�}��fd�}|g}t||�}|rvd}|d}	x|D]�}
|||
d!}||
d|
d!}||
d|
d!}
|
d}�|
d}|jtj||��yt|�}Wn6tk
rt�}d||f}t|��nXx=|D]5}|j��t|
||	|�}|j	|�qWqQW||}|jtj||��n|jtj||��|jd	�d
j
|�S(Ns	#line %d
csQ|jd�}y�|}Wn-tk
rLd�|f}t|��nX|S(Nis"line %d: no definition of key "%s"(RtKeyErrorR((tmatchR4tvalR7(tenvR(sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pytreplace�s
iiiiisline %d: %ss
R"(RRt
replace_reRR?R(Rtupdatetparse_stringtextendR(RRCRRtlinenoRDtcodetstructtoldendtnewlevelRtpreftheadttexttnewlinetenvlistteR7tnewenvtnewcodetsuff((RCRsC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyRG�s:
		



	



cCs2tg}|jt|tdd��dj|�S(NiiR"(theaderRHRGtglobal_namesR(RRJ((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyRs	s7(\n|\A)#include\s*['\"](?P<name>[\w\d./\\]+[.]src)['\"]cCs�tjj|�}t|�}g}x�|j�D]�}tj|�}|r�|jd�}tjj|�s�tjj	||�}ntjj
|�r�d|fGH|jt|��q�|j
|�q1|j
|�q1W|j�|S(NR4sIncluding file(tostpathtdirnametopent	readlinestinclude_src_reRARtisabsRtisfileRHtresolve_includesRtclose(tsourcetdtfidtlinesRtmtfn((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyRas 
cCs�t|�}tjj|�jdd�}ytdj|��}Wn0tk
rut�}td||f��nXd||fS(Ns\s\\R"sIn "%s" loop at %ss#line 1 "%s"
%s(	RaRYRZtnormcaseRDRRR(R(RcRft
sourcefileRJRS((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyR s
	cCsn|j�}t}d}xO|sidjg|D]}|| ^q.�}||kr`|d7}qt}qW|S(NiR"(tkeystFalseRtTrue(tadicttallkeystdonetnR tnewkey((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyt
unique_key+s	&

t__main__itrtwsIn %s loop at %s(0t__doc__t__all__RYtsystretnumpy.distutils.compatRRXRWRRtcompileRRR!R#R$R,R)R?RERGRtIR^RaRRst__name__targvtfilet
IndexErrortstdinRetstdouttoutfileR\RZtsplitexttbasetexttnewnametreadtallstrtwritestrR(RStwrite(((sC/usr/lib64/python2.7/site-packages/numpy/distutils/conv_template.pyt<module>PsT	 			6	,