ó °¿v]c@`sqdZddlmZmZmZddgZddlZddlZddlZej dej ƒZ ej dej ƒZ ej dej ƒZ d „Zej d ƒZej d ƒZej d ƒZd „Zd„Zej dƒZd„Zd„Zej dƒZd„Zd„Zej dej ƒZd„Zd„ZedƒZd„Zedkrmeƒ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-separated 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: i(tdivisiontabsolute_importtprint_functiont process_strt process_fileNs2(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\bs+\n\s*end\s*(subroutine|function)\b.*(\n|\Z)s\n (\$|\*)\s*function\bcC`sg}d}xtrtj||ƒ}|dkr7Pn|jƒ}tj|||jƒƒr´xStr°|jd||ƒ}|dkrŒPn|}|||d!dkraPqaqaWn|d7}t j||jƒƒ}|rì|jƒdpõt |ƒ}}|j ||fƒqW|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( tTruetroutine_start_retsearchtNonetstarttfunction_start_retmatchtendtrfindtroutine_end_retlentappend(tastrtspanlisttindtmR tiR ((sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-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*>cC`srtj|ƒ}i}xV|D]N}|djƒp;t|ƒ}|djddƒ}t|ƒ}|||\d+)\ZcC`s—|jdƒ}g|D]}|jƒ^q}xYtt|ƒƒD]E}tj||ƒ}|rAt|jdƒƒ}||||s @rightarrow@s\c`s›t|jdƒjddƒƒ}tj|ƒr8d|Sd}x-ˆjƒD]}ˆ||krK|}qKqKW|dkr“tˆƒ}|ˆ|(RR.Rttemplate_name_reR RR5R(tmobjR"R tkey(tlnames(sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-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.c`s.|jdƒ}ˆj|ˆd|gƒˆS(Ni(R.tget(R=R (tktrules(sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pytnamerepl´sR$s t>t<(RR#Rtsubtlist_reRt template_reRRBt ValueErrort startswithR*RtprintR/R+( tsubstrRR@tnumsubst base_ruletrR"RtruletnumREtnewstr((RCR?RDsm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pyt expand_sub„sF     .      (c C`s´|}d}t|ƒ}d}i}|jtƒxn|D]f}t|||d!ƒ\}}||7}|j|ƒ|t||d|d!|ƒ7}|d}q8W|||7}|S(NR$ii(Rtupdatet_special_namesR'RU( tallstrRTtwritestrtstructtoldendRRHt cleanedstrtdefs((sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pyRÀs     "s9(\n|\A)\s*include\s*['\"](?P[\w\d./\\]+[.]src)['\"]cC`sãtjj|ƒ}t|ƒ}g}x®|D]¦}tj|ƒ}|rÄ|jdƒ}tjj|ƒstjj||ƒ}ntjj |ƒr´t d|ƒ|j t |ƒƒqÑ|j |ƒq+|j |ƒq+W|jƒ|S(NR sIncluding file(tostpathtdirnametopentinclude_src_reR R.tisabsR/tisfileRMtextendtresolve_includesRtclose(tsourcetdtfidtlinestlineRtfn((sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pyRfÕs     cC`st|ƒ}tdj|ƒƒS(NR$(RfRR/(RhRk((sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pyRés sÿ <_c=s,d,c,z> <_t=real,double precision,complex,double complex> cC`sœytjd}Wn#tk r6tj}tj}n=Xt|dƒ}tjj|ƒ\}}|}t|dƒ}|j ƒ}t |ƒ}|j |ƒdS(NiRQtw( tsystargvt IndexErrortstdintstdoutRaR^R_tsplitexttreadRtwrite(tfileRjtoutfiletbasetexttnewnameRXRY((sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pytmain÷s     t__main__( t__doc__t __future__RRRt__all__R^RoR%tcompiletIRRR RRJRRIR#R'R,RRR<RURRbRfRRWR|t__name__(((sm/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/from_template.pyt/s8        <