ACC SHELL

Path : /usr/lib/python/lib2to3/fixes/
File Upload :
Current File : //usr/lib/python/lib2to3/fixes/fix_metaclass.pyo

Ñò
sÄMc@s›dZddklZddklZddklZlZlZl	Z	d„Z
d„Zd„Zd„Z
d	„Zd
„Zdeifd„ƒYZd
S(sŒFixer for __metaclass__ = X -> (metaclass=X) methods.

   The various forms of classef (inherits nothing, inherits once, inherints
   many) don't parse the same in the CST so we look at ALL classes for
   a __metaclass__ and if we find one normalize the inherits to all be
   an arglist.

   For one-liner classes ('class X: pass') there is no indent/dedent so
   we normalize those into having a suite.

   Moving the __metaclass__ into the classdef can also cause the class
   body to be empty so there is some special casing for that as well.

   This fixer also tries very hard to keep original indenting and spacing
   in all those corner cases.

i(t
fixer_base(ttoken(tNametsymstNodetLeafcCs·x°|iD]¥}|itijot|ƒS|itijon|iod|id}|itijo@|io6|id}t|tƒo|i	djot
Sq¯q
q
WtS(së we have to check the cls_node without changing it.
        There are two possiblities:
          1)  clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta')
          2)  clsdef => simple_stmt => expr_stmt => Leaf('__meta')
    it
__metaclass__(tchildrenttypeRtsuitet
has_metaclasstsimple_stmtt	expr_stmtt
isinstanceRtvaluetTruetFalse(tparenttnodet	expr_nodet	left_side((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pyR
s


cCsáx)|iD]}|itijodSq
WxAt|iƒD]$\}}|itijoPq<q<Wtdƒ‚ttigƒ}xE|i|do2|i|d}|i	|i
ƒƒ|iƒq…W|i	|ƒ|}dS(sf one-line classes don't get a suite in the parse tree so we add
        one to normalize the tree
    NsNo class suite and no ':'!i(RRRR	t	enumerateRtCOLONt
ValueErrorRtappend_childtclonetremove(tcls_nodeRtiR	t	move_node((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pytfixup_parse_tree-s"
		
c
Csõx9t|iƒD]$\}}|itijoPqqWdS|iƒttigƒ}tti	|gƒ}x=|i|o.|i|}|i
|iƒƒ|iƒqpW|i||ƒ|idid}|idid}	|	i
|_
dS(sÑ if there is a semi-colon all the parts count as part of the same
        simple_stmt.  We just want the __metaclass__ part so we move
        everything efter the semi-colon into its own simple_stmt node
    Ni(RRRRtSEMIRRRRRRRtinsert_childtprefix(
RRt	stmt_nodetsemi_indRtnew_exprtnew_stmtRt	new_leaf1t	old_leaf1((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pytfixup_simple_stmtGs"	

cCs=|io/|iditijo|idiƒndS(Niÿÿÿÿ(RRRtNEWLINER(R((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pytremove_trailing_newline_s$ccs
x5|iD]}|itijoPq
q
Wtdƒ‚xËtt|iƒƒD]´\}}|itijo•|io‹|id}|itijog|io]|id}t	|t
ƒo<|idjo,t|||ƒt
|ƒ|||fVqþqqNqNWdS(NsNo class suite!iu
__metaclass__(RRRR	RtlistRRRR
RRR(R*(RRRtsimple_nodeRt	left_node((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pyt
find_metasds 
	


cCsÄ|iddd…}x0|o(|iƒ}|itijoPqqWxt|ol|iƒ}t|tƒo/|itijo|io
d|_ndS|i	|iddd…ƒqLWdS(s› If an INDENT is followed by a thing with a prefix then nuke the prefix
        Otherwise we get in trouble when removing __metaclass__ at suite start
    Niÿÿÿÿu(
RtpopRRtINDENTR
RtDEDENTR!textend(R	tkidsR((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pytfixup_indent{s
#

tFixMetaclasscBseZdZd„ZRS(s
    classdef<any*>
    cCs!t|ƒpdSt|ƒd}x-t|ƒD]\}}}|}|iƒq/W|idi}t|iƒdjog|iditi	jo|id}q›|idi
ƒ}	tti	|	gƒ}|id|ƒn½t|iƒdjo&tti	gƒ}|i
d|ƒnt|iƒdjo^tti	gƒ}|i
dttidƒƒ|i
d|ƒ|i
dttidƒƒn
td	ƒ‚|idid}
d
|
_|
i}|io&|ittidƒƒd|
_n
d
|
_|id}d
|id_d
|id_|i|ƒt|ƒ|ipL|iƒt|dƒ}
||
_|i|
ƒ|ittidƒƒnŠt|iƒdjos|iditijoY|iditijo?t|dƒ}
|i
d|
ƒ|i
dttidƒƒndS(Niiiiiiu)u(sUnexpected class definitiont	metaclassu,u uiupassu
iþÿÿÿiÿÿÿÿ(R
RtNoneR.RRRtlenRtarglistRRt	set_childR RRtRPARtLPARRRR!RtCOMMAR4R)R0R1(tselfRtresultstlast_metaclassR	Rtstmtt	text_typeR9Rtmeta_txttorig_meta_prefixRt	pass_leaf((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pyt	transform—s`


 		

	




	
(t__name__t
__module__tPATTERNRF(((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pyR5‘sN(t__doc__tRtpygramRt
fixer_utilRRRRR
RR(R*R.R4tBaseFixR5(((s1/usr/lib/python2.6/lib2to3/fixes/fix_metaclass.pyt<module>s"						

ACC SHELL 2018