Your IP : 3.140.195.8


Current Path : /opt/alt/python33/lib64/python3.3/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/lib2to3/fixes/__pycache__/fix_idioms.cpython-33.pyo

�
��fc@smdZddlmZddlmZmZmZmZmZm	Z	dZ
dZGdd�dej�Z
dS(	u�Adjust some old Python 2 idioms to their modern counterparts.

* Change some type comparisons to isinstance() calls:
    type(x) == T -> isinstance(x, T)
    type(x) is T -> isinstance(x, T)
    type(x) != T -> not isinstance(x, T)
    type(x) is not T -> not isinstance(x, T)

* Change "while 1:" into "while True:".

* Change both

    v = list(EXPR)
    v.sort()
    foo(v)

and the more general

    v = EXPR
    v.sort()
    foo(v)

into

    v = sorted(EXPR)
    foo(v)
i(u
fixer_base(uCalluCommauNameuNodeu	BlankLineusymsu0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)u(power< 'type' trailer< '(' x=any ')' > >csr|EeZdZdZdeeeefZ�fdd�Zdd�Z	dd�Z
dd	�Zd
d�Z�S(
u	FixIdiomsu�
        isinstance=comparison< %s %s T=any >
        |
        isinstance=comparison< T=any %s %s >
        |
        while_stmt< 'while' while='1' ':' any+ >
        |
        sorted=any<
            any*
            simple_stmt<
              expr_stmt< id1=any '='
                         power< list='list' trailer< '(' (not arglist<any+>) any ')' > >
              >
              '\n'
            >
            sort=
            simple_stmt<
              power< id2=any
                     trailer< '.' 'sort' > trailer< '(' ')' >
              >
              '\n'
            >
            next=any*
        >
        |
        sorted=any<
            any*
            simple_stmt< expr_stmt< id1=any '=' expr=any > '\n' >
            sort=
            simple_stmt<
              power< id2=any
                     trailer< '.' 'sort' > trailer< '(' ')' >
              >
              '\n'
            >
            next=any*
        >
    csJtt|�j|�}|rFd|krF|d|dkrB|SdS|S(Nusorteduid1uid2(usuperu	FixIdiomsumatchuNone(uselfunodeur(u	__class__(u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyumatchOsuFixIdioms.matchcCsdd|kr|j||�Sd|kr8|j||�Sd|krT|j||�Std��dS(Nu
isinstanceuwhileusortedu
Invalid match(utransform_isinstanceutransform_whileutransform_sortuRuntimeError(uselfunodeuresults((u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyu	transformZsuFixIdioms.transformcCs�|dj�}|dj�}d|_d|_ttd�|t�|g�}d|kr�d|_ttjtd�|g�}n|j|_|S(NuxuTuu u
isinstanceununot(ucloneuprefixuCalluNameuCommauNodeusymsunot_test(uselfunodeuresultsuxuTutest((u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyutransform_isinstanceds		!	!uFixIdioms.transform_isinstancecCs*|d}|jtdd|j��dS(NuwhileuTrueuprefix(ureplaceuNameuprefix(uselfunodeuresultsuone((u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyutransform_whileps
uFixIdioms.transform_whilecCs=|d}|d}|jd�}|jd�}|rW|jtdd|j��nR|r�|j�}d|_|jttd�|gd|j��ntd��|j�|j}d	|kr9|r|jd	�d
|d
jf}	d	j	|	�|d
_q9t
�}
|jj|
�|jd	�d
|
_ndS(Nusortunextulistuexprusorteduprefixuushould not have reached hereu
i(
ugetureplaceuNameuprefixucloneuCalluRuntimeErroruremoveu
rpartitionujoinu	BlankLineuparentuappend_child(uselfunodeuresultsu	sort_stmtu	next_stmtu	list_callusimple_exprunewubtwnuprefix_linesuend_line((u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyutransform_sortts*

	
	 	uFixIdioms.transform_sortT(
u__name__u
__module__u__qualname__uTrueuexplicituTYPEuCMPuPATTERNumatchu	transformutransform_isinstanceutransform_whileutransform_sort(u
__locals__((u	__class__u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyu	FixIdioms%s'
u	FixIdiomsN(u__doc__uu
fixer_baseu
fixer_utiluCalluCommauNameuNodeu	BlankLineusymsuCMPuTYPEuBaseFixu	FixIdioms(((u=/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_idioms.pyu<module>s
.

?>