bgdZddgZddlZddlZddlZejdejZejdejZejdejZ dZ ejd Z ejd Z ejd Z d Zd ZejdZdZdZejdZdZdZejdejZdZdZedZdZedkr edSdS)a 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: process_str process_fileNz2(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\bz+\n\s*end\s*(subroutine|function)\b.*(\n|\Z)z\n (\$|\*)\s*function\bc"g}d} t||}|n|}t|||r4 |d||}|dkrn|}|||dzdkrn3|dz }t||}|r|dz pt|x}}| ||f |S) z 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. rTN z $) routine_start_researchstartfunction_start_rematchendrfindroutine_end_relenappend)astrspanlistindmr irs p/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/numpy/distutils/from_template.pyparse_structurer:s H C&  # #D# . . 9    " "4 8 8  JJtS%00b55!A#; **      ! !$ 0 0O!%%''!)0s4yy0c %%%!&" Oz<\s*(\w[\w\d]*)\s*>z<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>z<\s*((.*?))\s*>ct|}i}|D][}|dpt|}|ddd}t |}|||<\|S)Nrr \,@comma@)named_refindallstrip unique_keyreplaceconv)rrepsnamesrepnamereplthelists rfind_repl_patternsr+Ysy   D ! !D E1v||~~2E!2!21v~~eY//t**d Lrcjt|}tjtd|d}||fS)Nr)r+resubnr)rr&s rfind_and_remove_repl_patternsr0cs1 t $ $E 78R & &q )D ;rz\A\\(?P\d+)\ZcJ|d}d|D}tt|D]Q}t||}|r-t |d}||||<Rd|S)N,c6g|]}|S)r!).0xs r zconv..ks qrindex)splitrangeritem_rerintgroupjoin)rblrrjs rr$r$is 3AAA 3q66]] MM!A$    AGGG$$%%AQ4AaD 88A;;rczt|}d}d}|sd|z}||vr|dz }nd}||S)z( Obtain a unique key given a dictionary.Fr z__l%sT)listkeys)adictallkeysdonennewkeys rr"r"ss^5::<<  G D AA W   FAAD  Mrz\A\s*(\w[\w\d]*)\s*\Zc  |dd}|dd}t| td|} fd}t||}d}d}i t |D]}| vr׉ |||d}|td|z||vr| ds|||<d | d D}t|}| |}| |<|}||kr| |<td |d d |d |d |d މ s|S fd} d} t|D]# | t | |dzz } $| dd} | dd} | S)Nz\>z @rightarrow@z\c2t|ddd}t|rd|zSd}D]}||kr|}|t }||<d|zS)Nr rrz<%s>)r$r=r#template_name_rerrDr")mobjr*r(keylnamess rlistreplzexpand_sub..listreplstzz!}},,UI>>??  ! !' * * &W% %;;==  Cc{g%% <f%%D"F4L}rzNo replicates found for <%s>_c:g|]}|ddS)rr2)r#)r5rs rr7zexpand_sub..s&JJJ!AIIi--JJJrr2z*Mismatch in number of replacements (base <=z>) for . Ignoring.ct|d}|dz|gzS)Nr )r=get)rMr(kruless rnamereplzexpand_sub..namerepls5zz!}}yy!dV|,,Q//rr-z ><)r#r+rsublist_re template_rer rU ValueError startswithr9rprintr>r:)substrr&rPnumsubs base_rulerr*rulenumrXnewstrrVrOrWs @@@r expand_subrhsE ^^E> 2 2F ^^E= 1 1F  ' 'F \\'6 * *F     [[6 * *FGI E   ( (KK E>>jjEIIa$6$677G !?1!EFFF~~g&8&8&=&=~"aJJw}}S7I7IJJJDd))Ca a yy#((5+;"<"<"<"[\w\d./\\]+\.src)['\"]c\tj|}t|5}g}|D]}t|}|r|d}tj|s tj||}tj |r#| t|| || | dddn #1swxYwY|S)Nr() ospathdirnameopeninclude_src_rerr=isabsr>isfileextendresolve_includesr)sourcedfidlineslinerfns rr{r{sF A f # # #D$$T**A #WWV__w}}R((-a,,B7>>"%%'LL!1"!5!56666LL&&&& T"""" # # # # # # # # # # # # # # # # LsC%D!!D%(D%cdt|}td|S)Nr-)r{rr>)r|rs rrrs' V $ $E rwwu~~ & &&rz <_c=s,d,c,z> <_t=real,double precision,complex,double complex> cv tjd}t|d}tj|\}}|}t|d}n(#t $rtj}tj}YnwxYw| }t|}| |dS)Nr rdw) sysargvrvrsrtsplitext IndexErrorstdinstdoutreadrwrite)filer~baseextnewnameoutfilerlrms rmainrs %x{ 4oog&&t,, sw$$ i*XXZZF6""H MM(sA"A>=A>__main__)__doc____all__rsrr.compileIr rr rr]rr\r+r0r;r$r"rLrhrrwr{rrkr__name__r4rrrs--\ . ) 2:SUWUYZZJBDQQBJ=rtDD6bj/00 2:8 9 9 "*' ( ( "*, - -   2:677:::x&WY[Y]^^$'''$#%" zDFFFFFr