ó \ÐKc@sìdZddgZddlZddlZddlZiZdZd„Zd„Zej dƒZ ej d ƒZ d „Z ej d ƒZ ej d ƒZej d ƒZej dƒZd„Zej dƒZd„Zd„Zej dejƒZd„Zd„Zd„ZedkrèyejdZWn#ek rSejZej Z!n=Xe"edƒZej#j$eƒ\Z%Z&e%Z'e"e'dƒZ!ej(ƒZ)yee)ƒZ*Wn)e+k r×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 t process_strt process_fileiÿÿÿÿNsE /* ***************************************************************************** ** This file was autogenerated from a template DO NOT EDIT!!!! ** ** Changes should be made to the original source (.src) file ** ***************************************************************************** */ c Cs#|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((sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pytparse_structuregs,     $  cCs8|jdƒ}|jdƒ}dj|gt|ƒƒS(Niit,(tgrouptjointint(tobjttoreptnumrep((sA/usr/lib/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((sA/usr/lib/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]\}}||||R'tupdatet parse_stringtextendR(RRCRR tlinenoRDtcodetstructtoldendtnewlevelRtpreftheadttexttnewlinetenvlistRBR6tnewenvtnewcodetsuff((RCR sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pyRGÕs8         cCs2tg}|jt|tddƒƒdj|ƒS(NiiR!(theaderRHRGt global_namesR(RRJ((sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pyRs s7(\n|\A)#include\s*['\"](?P[\w\d./\\]+[.]src)['\"]cCsåtjj|ƒ}t|ƒ}g}x°|jƒD]¢}tj|ƒ}|rÆ|jdƒ}tjj|ƒs…tjj ||ƒ}ntjj |ƒr¶dG|GH|j t |ƒƒqÓ|j |ƒq1|j |ƒq1W|jƒ|S(NR3sIncluding file(tostpathtdirnametopent readlinestinclude_src_reR@RtisabsRtisfileRHtresolve_includesRtclose(tsourcetdtfidtlinesR tmtfn((sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pyR` s    cCs}t|ƒ}tjj|ƒjddƒ}ytdj|ƒƒ}Wn)tk rn}td||fƒ‚nXd||fS(Ns\s\\R!sIn "%s" loop at %ss#line 1 "%s" %s(R`RXRYtnormcaseRDRRR'(RbRet sourcefileRJRB((sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pyRs cCsn|jƒ}t}d}xO|sidjg|D]}|| ^q.ƒ}||kr`|d7}qt}qW|S(NiR!(tkeystFalseRtTrue(tadicttallkeystdonetnRtnewkey((sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pyt unique_key's  &   t__main__itrtwsIn %s loop at %s(.t__doc__t__all__RXtsystreRWRVRRtcompileRRR R"R#R+R(R>RERGRtIR]R`RRrt__name__targvtfilet IndexErrortstdinRdtstdouttoutfileR[RYtsplitexttbasetexttnewnametreadtallstrtwritestrR'RBtwrite(((sA/usr/lib/python2.7/site-packages/numpy/distutils/conv_template.pytPsP        6 +