AlkantarClanX12

Your IP : 3.145.106.7


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

�
��f�8c@s|dZddlmZddlmZddlmZmZddlm	Z
ddlmZdd	�Z
d
d�Zdd
�Zdd�ZdUdd�Zdd�Zdd�Zdd�Ze�e�dd�ZdUdUdd�Zdd�Zdd�ZdUd d!�Zd"d#�ZdUd$d%�ZdUd&d'�Zd(d)�Zd*d+�Zd,d-�Z d.d/�Z!e"d0d1d2d3d4d5d6d7d8d9g
�Z#d:d;�Z$d<a%d=a&d>a'dVa)d?d@�Z*dAdB�Z+dCdD�Z,dEdF�Z-dGdH�Z.dIdJ�Z/dKdL�Z0dMdN�Z1e"e
j2e
j3g�Z4dUdOdP�Z5e"e
j3e
j2e
j6g�Z7dQdR�Z8dUdSdT�Z9dUS(Wu1Utility functions, node construction macros, etc.i(uislicei(utoken(uLeafuNode(upython_symbols(upatcompcCs%ttj|ttjd�|g�S(Nu=(uNodeusymsuargumentuLeafutokenuEQUAL(ukeyworduvalue((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu
KeywordArgs	u
KeywordArgcCsttjd�S(Nu((uLeafutokenuLPAR(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuLParensuLParencCsttjd�S(Nu)(uLeafutokenuRPAR(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuRParensuRParencCslt|t�s|g}nt|t�s?d|_|g}nttj|ttjddd�g|�S(uBuild an assignment statementu u=uprefix(	u
isinstanceulistuprefixuNodeusymsuatomuLeafutokenuEQUAL(utargetusource((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuAssigns		uAssigncCsttj|d|�S(uReturn a NAME leafuprefix(uLeafutokenuNAME(unameuprefix((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuName&suNamecCs|ttjt�|g�gS(uA node tuple for obj.attr(uNodeusymsutraileruDot(uobjuattr((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuAttr*suAttrcCsttjd�S(uA comma leafu,(uLeafutokenuCOMMA(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuComma.suCommacCsttjd�S(uA period (.) leafu.(uLeafutokenuDOT(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuDot2suDotcCsMttj|j�|j�g�}|rI|jdttj|��n|S(u-A parenthesised argument list, used by Call()i(uNodeusymsutrailerucloneuinsert_childuarglist(uargsulparenurparenunode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuArgList6s$uArgListcCs:ttj|t|�g�}|dk	r6||_n|S(uA function callN(uNodeusymsupoweruArgListuNoneuprefix(u	func_nameuargsuprefixunode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuCall=suCallcCsttjd�S(uA newline literalu
(uLeafutokenuNEWLINE(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuNewlineDsuNewlinecCsttjd�S(uA blank lineu(uLeafutokenuNEWLINE(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu	BlankLineHsu	BlankLinecCsttj|d|�S(Nuprefix(uLeafutokenuNUMBER(unuprefix((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuNumberLsuNumbercCs1ttjttjd�|ttjd�g�S(uA numeric or string subscriptu[u](uNodeusymsutraileruLeafutokenuLBRACEuRBRACE(u
index_node((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu	SubscriptOsu	SubscriptcCsttj|d|�S(u
A string leafuprefix(uLeafutokenuSTRING(ustringuprefix((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuStringUsuStringc	Csd|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|r�d|_ttjd�}d|_|jttj||g��nttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S(uuA list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    uu uforuinuifu[u](
uprefixuLeafutokenuNAMEuappenduNodeusymsucomp_ifu	listmakerucomp_foruatomuLBRACEuRBRACE(	uxpufpuitutestufor_leafuin_leafu
inner_argsuif_leafuinner((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuListCompYs$							"$	uListCompcCsx|D]}|j�qWttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S(uO Return an import statement in the form:
        from package import name_leafsufromuprefixu uimport(uremoveuLeafutokenuNAMEuNodeusymsuimport_as_namesuimport_from(upackage_nameu
name_leafsuleafuchildrenuimp((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu
FromImportqs
u
FromImportc	Cs�t|t�r.|jt�t�gkr.dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS(u(Does the node represent a tuple literal?iiiiu(u)T(	u
isinstanceuNodeuchildrenuLParenuRParenuTrueulenuLeafuvalue(unode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuis_tuple�s*uis_tuplecCszt|t�oyt|j�dkoyt|jdt�oyt|jdt�oy|jdjdkoy|jdjdkS(u'Does the node represent a list literal?iiu[u]i����i����(u
isinstanceuNodeulenuchildrenuLeafuvalue(unode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuis_list�suis_listcCsttjt�|t�g�S(N(uNodeusymsuatomuLParenuRParen(unode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuparenthesize�suparenthesizeusortedulistusetuanyuallutupleusumuminumaxu	enumerateccs4t||�}x|r/|Vt||�}qWdS(ulFollow an attribute chain.

    If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
    use this to iterate over all objects in the chain. Iteration is
    terminated by getattr(x, attr) is None.

    Args:
        obj: the starting object
        attr: the name of the chaining attribute

    Yields:
        Each successive object in the chain.
    N(ugetattr(uobjuattrunext((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu
attr_chain�s	u
attr_chainuefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     u�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
u`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
cCs�ts<tjt�atjt�atjt�adantttg}xRt|t|d��D]8\}}i}|j	||�rd|d|krddSqdWdS(u Returns true if node is in an environment where all that is required
        of it is being iterable (ie, it doesn't matter if it returns a list
        or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        uparentunodeTF(u
pats_builtupatcompucompile_patternup0up1up2uTrueuzipu
attr_chainumatchuFalse(unodeupatternsupatternuparenturesults((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuin_special_context�s	%"uin_special_contextcCs�|j}|dk	r+|jtjkr+dS|j}|jtjtj	fkrSdS|jtj
kr||jd|kr|dS|jtjks�|jtj
kr�|dk	r�|jtjks�|jd|kr�dSdS(uG
    Check that something isn't an attribute or function name etc.
    iNFT(uprev_siblinguNoneutypeutokenuDOTuFalseuparentusymsufuncdefuclassdefu	expr_stmtuchildrenu
parametersu
typedargslistuCOMMAuTrue(unodeuprevuparent((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuis_probably_builtin�s		%uis_probably_builtincCspxi|dk	rk|jtjkr_t|j�dkr_|jd}|jtjkr_|jSn|j	}qWdS(uFind the indentation of *node*.iiuN(
uNoneutypeusymsusuiteulenuchildrenutokenuINDENTuvalueuparent(unodeuindent((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyufind_indentation�s'


ufind_indentationcCsW|jtjkr|S|j�}|jd}|_ttj|g�}||_|S(N(utypeusymsusuiteucloneuparentuNoneuNode(unodeuparentusuite((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu
make_suites	u
make_suitecCs;x4|jtjkr6|j}|std��qqW|S(uFind the top level namespace.u,root found before file_input node was found.(utypeusymsu
file_inputuparentu
ValueError(unode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu	find_roots
	u	find_rootcCs"t|t|�|�}t|�S(u� Returns true if name is imported from package at the
        top level of the tree which node belongs to.
        To cover the case of an import like 'import foo', use
        None for the package and 'foo' for the name. (ufind_bindingu	find_rootubool(upackageunameunodeubinding((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyudoes_tree_importsudoes_tree_importcCs|jtjtjfkS(u0Returns true if the node is an import statement.(utypeusymsuimport_nameuimport_from(unode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu	is_import"su	is_importcCs�dd�}t|�}t|||�r.dSd}}xtt|j�D]c\}}||�sfqHnx7t|j|d��D]\}}||�s�Pq�q�W||}PqHW|dkr xbt|j�D]N\}}|jtjkr�|jr�|jdjtjkr�|d}Pq�q�Wn|dkret
tjttj
d�ttj
|dd�g�}	n$t|ttj
|dd�g�}	|	t�g}
|j|t
tj|
��dS(	u\ Works like `does_tree_import` but adds an import statement
        if it was not imported. cSs,|jtjko+|jo+t|jd�S(Ni(utypeusymsusimple_stmtuchildrenu	is_import(unode((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyuis_import_stmt)su$touch_import.<locals>.is_import_stmtNiiuimportuprefixu (u	find_rootudoes_tree_importu	enumerateuchildrenutypeusymsusimple_stmtutokenuSTRINGuNoneuNodeuimport_nameuLeafuNAMEu
FromImportuNewlineuinsert_child(upackageunameunodeuis_import_stmturootu
insert_posuoffsetuidxunode2uimport_uchildren((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyutouch_import&s4
&

	!$utouch_importc	CsQxJ|jD]?}d}|jtjkrst||jd�rB|St|t|jd�|�}|r&|}q&n�|jtjtj	fkr�t|t|jd	�|�}|r&|}q&ng|jtj
kr�t|t|jd�|�}|r�|}q&x$t|jdd��D]b\}}|jtj
kr|jdkrt|t|j|d�|�}|r{|}q{qqWn�|jtkr�|jdj|kr�|}nvt|||�r�|}n[|jtjkr�t|||�}n4|jtjkr&t||jd�r&|}q&n|r
|s6|St|�rI|Sq
q
WdS(
u� Returns the node which binds variable name, otherwise None.
        If optional argument package is supplied, only imports will
        be returned.
        See test cases for examples.iiiNu:iii����i����(uchildrenuNoneutypeusymsufor_stmtu_findufind_bindingu
make_suiteuif_stmtu
while_stmtutry_stmtu	enumerateutokenuCOLONuvalueu	_def_symsu_is_import_bindingusimple_stmtu	expr_stmtu	is_import(unameunodeupackageuchilduretunuiukid((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyufind_bindingTsH	&!#%		ufind_bindingcCs||g}xl|rw|j�}|jdkrO|jtkrO|j|j�q|jtjkr|j|kr|SqWdS(Ni(	upoputypeu_block_symsuextenduchildrenutokenuNAMEuvalueuNone(unameunodeunodes((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu_finds		!u_findcCs'|jtjkr|r|jd}|jtjkr�x�|jD]Z}|jtjkrw|jdj|kr�|SqB|jtjkrB|j|krB|SqBWq#|jtjkr�|jd}|jtjkr|j|kr|Sq#|jtjkr#|j|kr#|Sn|jtj	kr#|rMt
|jd�j�|krMdS|jd}|rst
d|�rsdS|jtjkr�t
||�r�|S|jtjkr�|jd}|jtjkr |j|kr |Sq#|jtjkr|j|kr|S|r#|jtjkr#|SndS(u� Will reuturn node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. iiiuasi����N(utypeusymsuimport_nameuchildrenudotted_as_namesudotted_as_nameuvalueutokenuNAMEuimport_fromustrustripuNoneu_finduimport_as_namesuimport_as_nameuSTAR(unodeunameupackageuimpuchildulastun((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu_is_import_binding�s@
!
!!%
!
!!u_is_import_bindingNF(:u__doc__u	itertoolsuisliceupgen2utokenupytreeuLeafuNodeupygramupython_symbolsusymsuupatcompu
KeywordArguLParenuRParenuAssignuNoneuNameuAttruCommauDotuArgListuCalluNewlineu	BlankLineuNumberu	SubscriptuStringuListCompu
FromImportuis_tupleuis_listuparenthesizeusetuconsuming_callsu
attr_chainup0up1up2uFalseu
pats_builtuin_special_contextuis_probably_builtinufind_indentationu
make_suiteu	find_rootudoes_tree_importu	is_importutouch_importuclassdefufuncdefu	_def_symsufind_bindingutraileru_block_symsu_findu_is_import_binding(((u7/opt/alt/python33/lib64/python3.3/lib2to3/fixer_util.pyu<module>sZ		-*