Ñò þg6Fc @sÌdZddkZddkZddkZddkZddkZddkZyddklZWn#e j oddklZnXei e ƒZ d„Z dd„Zd„Zdd d „ƒYZdS( s’Simple traceback introspection. Used to add additional information to AssertionErrors in tests, so that failure messages may be more informative. iÿÿÿÿN(tStringIOc Cs´tid|ƒx|io |i}qW|i}t|ƒ\}}t||ƒ\}}ttidi |ƒƒƒ}t |i |i ƒ}xœ|o”yt i |i|ƒWnut ij of}tid|ƒ|idƒ|d8}ttidi |ƒƒƒ}t |i |i ƒ}q‘nXPq‘Wg} |ioj|iidƒ} d} xO| D]C} | |jo| id| ƒn| id| ƒ| d7} q\Wndi | ƒS( sÞInspect a traceback and its frame, returning source for the expression where the exception was raised, with simple variable replacement performed and the line on which the exception was raised marked with '>>' sinspect traceback %stsTokenizer error: %siis s>> s (tlogtdebugttb_nextttb_framettbsourcetfind_inspectable_linesRttextwraptdedenttjointExpandertf_localst f_globalsttokenizetreadlinet TokenErrortpoptexpanded_sourcetsplittappend( ttbtframetlinestexc_linet inspect_linest mark_linetsrctexptetpaddedt exp_linesteptline((s2/usr/lib/python2.6/site-packages/nose/inspector.pytinspect_tracebacks@      ic Cs`|i}|i}|djo|d|d}tid||ƒyti|ƒ\}}Wntj od}}qCX|}t|dƒ}tdt |t |ƒ|ƒƒ}||||!}|d|}t i d joR|djoExB||di ƒidƒo|d8}||||!}qóWqCn d}}tid||ƒ||fS( sGet source from a traceback object. A tuple of two things is returned: a list of lines of context from the source code, and the index of the current line within that list. The optional second argument specifies the number of lines of context to return, which are centered around the current line. NOTE: This is adapted from inspect.py in the python 2.4 standard library, since a bug in the 2.3 version of inspect prevents it from correctly locating source lines in a traceback frame. iiislineno: %s start: %sis\s'tbsource lines '''%s''' around index %sN(ii(t tb_linenoRRRtinspectt findsourcetIOErrortNonetmaxtmintlentsyst version_infotstriptendswith( RtcontexttlinenoRtstartRtdummytindext all_lines((s2/usr/lib/python2.6/site-packages/nose/inspector.pyR@s,   "  c Csžtidƒ}tidƒ}tidƒ}g}||}|i|ƒiƒd}|t|ddƒ|!}|iƒ||dt|dt|ƒƒ!} x@|D]8} |i| ƒiƒd|jo|i| ƒq¥Pq¥W|iƒ|i|ƒt|ƒd} |i |ƒ} xg| D]_} | p |i| ƒiƒd|jo1|i | ƒ o |i| ƒ|i | ƒ} qPqWt i d|| ƒ|| fS( s'Find lines in home that are inspectable. Walk back from the err line up to 3 lines, but don't walk back over changes in indent level. Walk forward up to 3 lines, counting \ separated lines as 1. Don't walk over changes in indent level (unless part of an extended line) s \\[\s\n]*$s :[\s\n]*$s^(\s*)iiiis#Inspecting lines '''%s''' around %s( tretcompiletmatchtgroupsR(treverseR)R*RtsearchRR( Rtpostcnttdftindt toinspectthomet home_indenttbeforetafterR!thome_post continued((s2/usr/lib/python2.6/site-packages/nose/inspector.pyRms6   $   ' R cBs eZdZd„Zd„ZRS(sxSimple expression expander. Uses tokenize to find the names and expands any that can be looked up in the frame. cCs(||_||_d|_d|_dS(NR(tlocalstglobalsR'tlposR(tselfRFRG((s2/usr/lib/python2.6/site-packages/nose/inspector.pyt__init__™s   cCs”|idj o6|d|ijo"|id|d|i7_n0|d|ijo|id|d7_n|d|_|tijonÍ|tijo­y4|i|}t|ƒo |}n t|ƒ}Wnct j oWy4|i |}t|ƒo |}n t|ƒ}Wq@t j o |}q@XnX|i|7_n|i|7_t i d||dƒo|id7_ndS(Nit s\s+\\\ns \ ( RHR'RRtINDENTtNAMERFtcallabletreprtKeyErrorRGR5R7(RItttypettokR1tendR!tval((s2/usr/lib/python2.6/site-packages/nose/inspector.pyt__call__Ÿs2 $"       (t__name__t __module__t__doc__RJRU(((s2/usr/lib/python2.6/site-packages/nose/inspector.pyR •s ((RXR$tloggingR5R+RRt cStringIORt ImportErrort getLoggerRVRR"RRR (((s2/usr/lib/python2.6/site-packages/nose/inspector.pyts       . - (