U if @srddlmZddlmZddlmZmZmZddZddZ dd Z d d Z d d Z ddZ GdddejZdS)) fixer_base)token)symsNodeLeafcCsz|jD]n}|jtjkr"t|S|jtjkr|jr|jd}|jtjkr|jr|jd}t|tr|j dkrdSqdS)N __metaclass__TF) childrentypersuite has_metaclass simple_stmt expr_stmt isinstancervalue)parentnode expr_nodeZ left_sider@/opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_metaclass.pyr s      r cCs|jD]}|jtjkrdSqt|jD]\}}|jtjkr(qJq(tdttjg}|j|ddr|j|d}| | | qV| ||}dS)NzNo class suite and no ':'!) r r rr enumeraterCOLON ValueErrorr append_childcloneremove)cls_noderir move_noderrrfixup_parse_tree-s      r c Cst|jD]\}}|jtjkr q(q dS|ttjg}ttj |g}|j|drz|j|}| | |qJ| |||jdjd}|jdjd} | j |_ dS)Nr)rr r rSEMIrrrrr rr insert_childprefix) rrZ stmt_nodeZsemi_indrZnew_exprZnew_stmtrZ new_leaf1Z old_leaf1rrrfixup_simple_stmtGs     r$cCs*|jr&|jdjtjkr&|jddS)N)r r rNEWLINEr)rrrrremove_trailing_newline_sr'ccs|jD]}|jtjkrq$qtdtt|jD]t\}}|jtjkr2|jr2|jd}|jtjkr2|jr2|jd}t |t r2|j dkr2t |||t ||||fVq2dS)NzNo class suite!rr)r r rr rlistrr rrrrr$r')rrrZ simple_noderZ left_noderrr find_metasds      r)cCsz|jddd}|r,|}|jtjkrq,q|rv|}t|tr^|jtjkr^|jrZd|_dS| |jdddq,dS)Nr%) r popr rINDENTrrDEDENTr#extend)r Zkidsrrrr fixup_indent{s r/c@seZdZdZdZddZdS) FixMetaclassTz classdef cCs8t|s dSt|d}t|D]\}}}|}|q |jdj}t|jdkr|jdjtjkrp|jd}n(|jd } t tj| g}| d|nt|jdkrt tjg}| d|nZt|jdkrt tjg}| dt tjd| d|| dt tjdntd |jdjd} d | _| j} |jrZ|t tjd d | _nd | _|jd} d | jd_d | jd_||t||js|t |d} | | _|| |t tjdnbt|jdkr4|jdjtjkr4|jdjtjkr4t |d} | d| | dt tjddS)Nrr)(zUnexpected class definition metaclass, r*rpass r%)r r r)rr r lenrarglistrrZ set_childr"rrRPARLPARrrr#rCOMMAr/r&r,r-)selfrZresultsZlast_metaclassr rZstmtZ text_typer>rZmeta_txtZorig_meta_prefixrZ pass_leafrrr transformsb              zFixMetaclass.transformN)__name__ __module__ __qualname__Z BM_compatibleZPATTERNrCrrrrr0sr0N)r*rZpygramrZ fixer_utilrrrr r r$r'r)r/ZBaseFixr0rrrrs