ó ™ÙÊKc@sÔdZddgZddlZddlZddlZejdejƒZejdejƒZejdejƒZ d„Z ejd ƒZ ejd ƒZ ejd ƒZ d „Zejd ƒZd„Zd„ZejdƒZd„Zd„ZejdejƒZd„Zd„ZedƒZedkrÐyejdZWn#ek rkejZejZ n=Xe!edƒZej"j#eƒ\Z$Z%e$Z&e!e&dƒZ ej'ƒZ(ee(ƒZ)e j*e)ƒndS(sÆ process_file(filename) takes templated file .xxx.src and produces .xxx file where .xxx is .pyf .f90 or .f using the following template rules: '<..>' denotes a template. All function and subroutine blocks in a source file with names that contain '<..>' will be replicated according to the rules in '<..>'. The number of comma-separeted words in '<..>' will determine the number of replicates. '<..>' may have two different forms, named and short. For example, named: where anywhere inside a block '

' will be replaced with 'd', 's', 'z', and 'c' for each replicate of the block. <_c> is already defined: <_c=s,d,c,z> <_t> is already defined: <_t=real,double precision,complex,double complex> short: , a short form of the named, useful when no

appears inside a block. In general, '<..>' contains a comma separated list of arbitrary expressions. If these expression must contain a comma|leftarrow|rightarrow, then prepend the comma|leftarrow|rightarrow with a backslash. If an expression matches '\' then it will be replaced by -th expression. Note that all '<..>' forms in a block must have the same number of comma-separated entries. Predefined named template rules: t process_strt process_fileiÿÿÿÿNs2(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\bs+\n\s*end\s*(subroutine|function)\b.*(\n|\Z)s\n (\$|\*)\s*function\bcCs g}d}xötj||ƒ}|dkr1Pn|jƒ}tj|||jƒƒr§xL|jd||ƒ}|dkr€Pn|}|||d!dkr[Pq[q[n|d7}tj||jƒƒ}|rß|jƒdpèt |ƒ}}|j ||fƒq|S(s‘ Return a list of tuples for each function or subroutine each tuple is the start and end of a subroutine or function to be expanded. is iÿÿÿÿis $iN( troutine_start_retsearchtNonetstarttfunction_start_retmatchtendtrfindtroutine_end_retlentappend(tastrtspanlisttindtmRtiR((sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pytparse_structure;s(     &s<\s*(\w[\w\d]*)\s*>s<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>s<\s*((.*?))\s*>cCsrtj|ƒ}i}xV|D]N}|djƒp;t|ƒ}|djddƒ}t|ƒ}|||\d+)\ZcCs—|jdƒ}g|D]}|jƒ^q}xYtt|ƒƒD]E}tj||ƒ}|rAt|jdƒƒ}||||s @rightarrow@s\cs›t|jdƒjddƒƒ}tj|ƒr8d|Sd}x-ˆjƒD]}ˆ||krK|}qKqKW|dkr“tˆƒ}|ˆ|(RR&Rttemplate_name_reRRR,R(tmobjRRtkey(tlnames(sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pytlistrepl„s!    sNo replicates found for <%s>t_R s@comma@sHMismatch in number of replacements (base <%s=%s>) for <%s=%s>. Ignoring.cs.|jdƒ}ˆj|ˆd|gƒˆS(Ni(R&tget(R5R(tktrules(sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pytnamerepl¯sts t>t<(RRRtsubtlist_reRt template_reRR:t ValueErrort startswithR"R R'R#( tsubstrRR8tnumsubst base_ruletrRRtruletnumR=tnewstr((R;R7R<sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pyt expand_sub~sJ     .      cCs³|}d}t|ƒ}d}i}|jtƒxm|D]e}||||d!7}|jt|||d!ƒƒ|t||d|d!|ƒ7}|d}q8W|||7}|S(NR>ii(Rtupdatet_special_namesRRM(tallstrRLtwritestrtstructtoldendRRA((sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pyR»s   "s9(\n|\A)\s*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(NRsIncluding file(tostpathtdirnametopent readlinestinclude_src_reRR&tisabsR'tisfiletextendtresolve_includesR tclose(tsourcetdtfidtlinestlineRtfn((sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pyR]Ïs    cCst|ƒ}tdj|ƒƒS(NR>(R]RR'(R_Rb((sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pyRãs sÿ <_c=s,d,c,z> <_t=real,double precision,complex,double complex> t__main__iRItw(+t__doc__t__all__RTtsystretcompiletIRR RRRCRRBRR$RRR4RMRRYR]RROt__name__targvtfilet IndexErrortstdinRatstdouttoutfileRWRUtsplitexttbasetexttnewnametreadRPRQtwrite(((sA/usr/lib/python2.7/site-packages/numpy/distutils/from_template.pyt/sH        =