id@%dZddgZddlZddlZddlZiZdZdZdZej dZ ej d Z d Z ej d Z ej d Zej d Zej dZdZej dZdZdZej dejZdZdZdZdZedkr edSdS)aX 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 exclude particular combinations of the variables using (inside the comment portion of the inner loop): :exclude: var1=value1, var2=value2, ... This will exclude 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 process_str process_fileNaE /* ***************************************************************************** ** This file was autogenerated from a template DO NOT EDIT!!!! ** ** Changes should be made to the original source (.src) file ** ***************************************************************************** */ c |dkrd}d}n d|z}d|z}d}d}g} |||}|dkrn|d|}|d |}|||} |d | } ||d ||d zz }|||d z| | d z|f||d |d z| z }| }||S) z The returned line number is from the beginning of the string, starting at zero. Returns an empty list if no loops found. rz/**begin repeatz/**end repeat**/z/**begin repeat%dz/**end repeat%d**/Tz*/ )findcountappendsort) astrlevelloopbegloopendindlinespanliststartstart2fini1fini2s R/opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/distutils/conv_template.pyparse_structurergs+  zz#$%-&. C DH  '3'' B;; 4''4(( '6** $&&  4fQh///q%q$?@@@  45111  MMOOO Oc|d}|d}d|gt|zS)Nr,)groupjoinint)objtorepnumreps r paren_replr$s? IIaLLE YYq\\F 88UGCKK' ( ((rz\(([^)]*)\)\*(\d+)z([^*]+)\*(\d+)ctt|}dd|dD}|dS)Nrcrg|]4}tt|5S)plainrepsubr$strip).0xs r z parse_values..s>///\\*aggii88///r)parenrepr)r$rsplit)r s r parse_valuesr0s` << D ) )D 88//"jjoo/// 0 0D ::c??rz\n\s*\*?z#\s*(\w*)\s*=([^#]*)#z (\w*)=(\w*)z :exclude:ctd|}g}t|}d}|D]h}|d}t |d}t |}||}n||krd}t |||||fz|||fig} t |D]~} | } | d| d} || d| } t| }| t|g}|t dt|D]%fd|D}||&|S) aFind 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'[,...]}, ...] Nrrz.Mismatch in number of values, %d != %d %s = %srzNo substitution variables foundc(i|]\}}||Sr'r')r+namevalsis r z%parse_loop_header..s#555ttT!W555r)stripastr)named_refindallr0len ValueErrorr exclude_refinditerspanr exclude_vars_redictrange)loopheadnamesrepsnsubrepr4r5sizemsgexcludesr!r?endlinesubstrex_namesdlisttmpr6s @rparse_loop_headerrPs||B))H E   H % %D D # #1vCF##4yy <DD T\\CCSD$d#;;<< < dD\""""H""8,,((xxzz--d1g..$q''/*"**622X'''' E |:;;; 4[[5555u555 S Lrz@(\w+)@cpdz}fd}|g}t||}|r}|t| || |}||?||d}|t||n.|t|||d d |S) Nz #line %d c|d} |}n%#t$rd|fz}t|dwxYw|S)Nrz"line %d: no definition of key "%s")rKeyErrorr<)matchr4valrIenvrs rreplacezparse_string..replaces`{{1~~ ,d)CC , , ,6d|CCS//t + , s !"Arrrz line %d: %srr2) rr replace_rer)rPr<update parse_stringextendr)r rVrrlinenorWcodestructoldendnewlevelr)prefheadtextnewlineenvlisterInewenvnewcodesuffs ` ` rr\r\s D F 8D T5 ) )F 319 % %Cs1v &DAs1v &DAs1v &DVFSVmG KK w55 6 6 6 &+D11 & & &#wl2 oo% &" % % c"""&tVXwGG G$$$$ %FGG} JNN7D112222 JNN7D11222KK 774==s-B== C"CC"ctg}|t|tddd|S)Nrrr2)headerr]r\ global_namesr)r r_s rrrs9 8DKK T<A66777 774==rz7(\n|\A)#include\s*['\"](?P[\w\d./\\]+[.]src)['\"]c\tj|}t|5}g}|D]}t|}|r|d}tj|s tj||}tj |r#| t|| || | dddn #1swxYwY|S)Nr4) ospathdirnameopeninclude_src_rerTrisabsrisfiler]resolve_includesr )sourcedfidlinesrmfns rrwrwsF A f # # #D$$T**A #WWV__w}}R((-a,,B7>>"%%'LL!1"!5!56666LL&&&& T"""" # # # # # # # # # # # # # # # # LsC%D!!D%(D%c.t|}tj|dd} t d|}n(#t$r}td|d|dd}~wwxYwd|d|S)N\z\\r2zIn "z " loop at z #line 1 "z" )rwrprqnormcaserWrrr<)rxr{ sourcefiler_rhs rrrs V $ $E!!&))11$??JK2775>>** KKKjQQ?@@dJK ",TT 22s"A'' B 1BB ct|}d}d|s/dfd|D}||vrdz nd}|/|S)NFrr2c$g|] }|d S)Nr')r+r,ns rr-zunique_key..,s!111A!BQB%111rT)listkeysr)adictallkeysdonenewkeyrs @r unique_keyr#s~ 5::<<  G D A111111122 W   FAAD  Mrc tjd}t|d}tj|\}}|}t|d}n(#t $rtj}tj}YnwxYw| } t|}n(#t$r}td|d|dd}~wwxYw| |dS)NrrwzIn z loop at ) sysargvrsrprqsplitext IndexErrorstdinstdoutreadrr<write) filerzbaseextnewnameoutfileallstrwritestrrhs rmainr4s %x{ 4oog&&t,, sw$$ i*XXZZFCv&& CCCjtttQQ788dBC MM(s)A"A>=A>B&& C 0CC __main__)__doc____all__rprrernrmrr$compiler.r(r0r8r9r@r=rPrZr\rIrtrwrrr__name__r'rrrsNN` . )  @))) 2:+ , , 2:' ( (    2:k " " 2:. / /"*^,, RZ $ $ 222hRZ # # )))V @ACGG$333"( zDFFFFFr