ó žòœMc@s dZddlmZmZmZddlZdefd„ƒYZdefd„ƒYZdefd „ƒYZ d efd „ƒYZ d e fd „ƒYZ dS(skutilities for analyzing expressions and blocks of Python code, as well as generating Python from AST nodesiÿÿÿÿ(t exceptionstpyparsertutilNt PythonCodecBseZdZd„ZRS(s<represents information about a string containing Python codecKsw||_tƒ|_tƒ|_t|tƒrNtj|jƒd|}n|}tj ||}|j |ƒdS(Ntexec( tcodetsettdeclared_identifierstundeclared_identifierst isinstancet basestringRtparsetlstriptFindIdentifierstvisit(tselfRtexception_kwargstexprtf((s./usr/lib/python2.7/vendor-packages/mako/ast.pyt__init__s   (t__name__t __module__t__doc__R(((s./usr/lib/python2.7/vendor-packages/mako/ast.pyR st ArgumentListcBseZdZd„ZRS(sBparses a fragment of code as a comma-separated list of expressionscKs¯g|_g|_tƒ|_tƒ|_t|tƒrƒtjd|ƒrktjd|ƒ rk|d7}nt j |d|}n|}t j |t |}|j |ƒdS(Ns\Ss,\s*$t,R(tcodeargstargsRRRR R tretmatchRR t FindTupleRR(RRRRR((s./usr/lib/python2.7/vendor-packages/mako/ast.pyR+s    % (RRRR(((s./usr/lib/python2.7/vendor-packages/mako/ast.pyR)stPythonFragmentcBseZdZd„ZRS(s°extends PythonCode to provide identifier lookups in partial control statements e.g. for x in 5: elif y==9: except (MyException, e): etc. cKs%tjd|jƒtjƒ}|s=tjd||‚n|jdƒrb||jdƒ }n|jddƒ\}}|dkr“|d }nu|d kr¬|d }n\|d ksÄ|d krÕd|d }n3|dkròd|d }ntjd||‚tt |ƒj ||dS(Ns^(\w+)(?:\s+(.*?))?:\s*(#|$)s0Fragment '%s' is not a partial control statementiiitfortiftwhiletpassttryspass except:passteliftelsesif False:pass texcepts try:pass s!Unsupported control keyword: '%s'(sforsifswhile( RRtstriptSRtCompileExceptiontgrouptstarttsuperRR(RRRtmtkeywordR((s./usr/lib/python2.7/vendor-packages/mako/ast.pyREs(      (RRRR(((s./usr/lib/python2.7/vendor-packages/mako/ast.pyR<st FunctionDeclcBs&eZdZed„Zed„ZRS(sfunction declarationcKs™||_tj|d|}tj||}|j|ƒt|dƒsetjd||‚n| r•|jr•tjd|j d|‚ndS(NRtfuncnames'Code '%s' is not a function declarations('**%s' keyword argument not allowed hereiÿÿÿÿ( RRR t ParseFuncRthasattrRR)tkwargstargnames(RRt allow_kwargsRRR((s./usr/lib/python2.7/vendor-packages/mako/ast.pyR_s   c Cs g}g|jD] }|^q}|j}|j}g|jD] }|^q>}|jƒx¬|D]¤} d} |r†d| } t}n7|rŸd| } t}nt|ƒr·|jƒpºd} |rõ| rõ|j dd| t j | ƒj ƒfƒqa|j d| ƒqaW|S(sJreturn the argument declarations of this FunctionDecl as a printable list.s**t*is%s=%sN( tdefaultsR3tvarargsR4treversetNonetFalsetlentpoptinsertRtExpressionGeneratortvalue( Rtinclude_defaultst namedeclstdR7R3R8RR4targtdefault((s./usr/lib/python2.7/vendor-packages/mako/ast.pytget_argument_expressionsns*          (RRRtTrueRRF(((s./usr/lib/python2.7/vendor-packages/mako/ast.pyR/]s t FunctionArgscBseZdZd„ZRS(s.the argument portion of a function declarationcKs!tt|ƒjd||dS(Nsdef ANON(%s):pass(R,RHR(RRR3((s./usr/lib/python2.7/vendor-packages/mako/ast.pyRŽs(RRRR(((s./usr/lib/python2.7/vendor-packages/mako/ast.pyRH‹s( RtmakoRRRRtobjectRRRR/RH(((s./usr/lib/python2.7/vendor-packages/mako/ast.pyts !.