ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/usr/lib64/python2.7/lib2to3/fixes/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pyo

�
{fc@s�dZddlmZddlmZddlmZmZmZm	Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zdejfd��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�|jD]�}|jtjkr,t|�S|jtjkr
|jr
|jd}|jtjkr�|jr�|jd}t|t�r�|j	dkr�t
Sq�q
q
WtS(s� we have to check the cls_node without changing it.
        There are two possibilities:
          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((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pyR
s


cCs�x'|jD]}|jtjkr
dSq
Wx?t|j�D]"\}}|jtjkr:Pq:q:Wtd��ttjg�}xC|j|dr�|j|d}|j	|j
��|j�q�W|j	|�|}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((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pytfixup_parse_tree-s
c
Cs�x7t|j�D]"\}}|jtjkrPqqWdS|j�ttjg�}ttj	|g�}x;|j|r�|j|}|j
|j��|j�qnW|j||�|jdjd}|jdjd}	|	j
|_
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 after the semi-colon into its own simple_stmt node
    Ni(RRRRtSEMIRRRRRRRtinsert_childtprefix(
RRt	stmt_nodetsemi_indRtnew_exprtnew_stmtRt	new_leaf1t	old_leaf1((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pytfixup_simple_stmtGs

cCs:|jr6|jdjtjkr6|jdj�ndS(Ni����(RRRtNEWLINER(R((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pytremove_trailing_newline_s"ccs�x3|jD]}|jtjkr
Pq
q
Wtd��x�tt|j��D]�\}}|jtjkrL|jrL|jd}|jtjkr�|jr�|jd}t	|t
�r�|jdkr�t|||�t
|�|||fVq�q�qLqLWdS(NsNo class suite!iu
__metaclass__(RRRR	RtlistRRRR
RRR(R*(RRRtsimple_nodeRt	left_node((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pyt
find_metasds"


cCs�|jddd�}x,|rD|j�}|jtjkrPqqWxm|r�|j�}t|t�r�|jtjkr�|jr�d|_ndS|j	|jddd��qHWdS(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((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pytfixup_indent{s		!	tFixMetaclasscBseZeZdZd�ZRS(s
    classdef<any*>
    cCst|�sdSt|�d}x-t|�D]\}}}|}|j�q-W|jdj}t|j�dkr�|jdjtj	kr�|jd}q�|jdj
�}	ttj	|	g�}|jd|�n�t|j�dkrttj	g�}|j
d|�n~t|j�dkr�ttj	g�}|j
dttjd��|j
d|�|j
dttjd��ntd	��|jdjd}
d
|
_|
j}|jr�|jttjd��d|
_n	d
|
_|jd}d
|jd_d
|jd_|j|�t|�|js�|j�t|d�}
||
_|j|
�|jttjd��n�t|j�dkr|jdjtjkr|jdjtjkrt|d�}
|j
d|
�|j
dttjd��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((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pyt	transform�s^
				


	
	
(t__name__t
__module__Rt
BM_compatibletPATTERNRF(((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pyR5�sN(t__doc__tRtpygramRt
fixer_utilRRRRR
RR(R*R.R4tBaseFixR5(((s3/usr/lib64/python2.7/lib2to3/fixes/fix_metaclass.pyt<module>s"						

Zerion Mini Shell 1.0