ó ¿œ^c@sºdZddlZddlZddlZddlZddlZddlmZmZd„Zddd„ƒYZ ddd„ƒYZ d e e fd „ƒYZ d e fd „ƒYZ d e e fd„ƒYZ dd„ZejejdgffZejejejejejejejejejejejejejejej ej!ej"ej#ej$dgfffffffffffffffffej%dfffZ&dS(süSimple code to extract class & function docstrings from a module. This code is used as an example in the library reference manual in the section on using the parser module. Refer to the manual for a thorough discussion of the operation of this code. iÿÿÿÿN(tListTypet TupleTypecCsVt|ƒjƒ}tjjtjj|ƒdƒ}tj|ƒ}t|j ƒ|ƒS(s‡Retrieve information from the parse tree of a source file. fileName Name of the file to read Python source code from. i( topentreadtostpathtbasenametsplitexttparsertsuitet ModuleInfottotuple(tfileNametsourceRtast((s+/usr/lib64/python2.7/Demo/parser/example.pytget_docss"t SuiteInfoBasecBsVeZdZdZdd„Zd„Zd„Zd„Zd„Z d„Z d„Z RS( tcCs,i|_i|_|r(|j|ƒndS(N(t _class_infot_function_infot _extract_info(tselfttree((s+/usr/lib64/python2.7/Demo/parser/example.pyt__init__!s  cCst|ƒdkr2ttd|dƒ\}}ntt|dƒ\}}|rgt|dƒ|_nx¨|dD]œ}tt|ƒ\}}|rr|d}|dtjkrÔ|dd}t|ƒ|j |scCs |jjƒS(N(Rtkeys(R((s+/usr/lib64/python2.7/Demo/parser/example.pytget_class_namesAscCs |j|S(N(R(RR)((s+/usr/lib64/python2.7/Demo/parser/example.pytget_class_infoDscCs/y|j|SWntk r*|j|SXdS(N(RtKeyErrorR(RR)((s+/usr/lib64/python2.7/Demo/parser/example.pyt __getitem__Gs N( t__name__t __module__RR+tNoneRRR*R,R.R/R1(((s+/usr/lib64/python2.7/Demo/parser/example.pyRs      t SuiteFuncInfocBseZd„Zd„ZRS(cCs |jjƒS(N(RR-(R((s+/usr/lib64/python2.7/Demo/parser/example.pytget_function_namesQscCs |j|S(N(R(RR)((s+/usr/lib64/python2.7/Demo/parser/example.pytget_function_infoTs(R2R3R6R7(((s+/usr/lib64/python2.7/Demo/parser/example.pyR5Ns R"cBseZdd„ZRS(cCs5|dd|_tj||r*|dp-dƒdS(Niiiÿÿÿÿ(R+RRR4(RR((s+/usr/lib64/python2.7/Demo/parser/example.pyRYsN(R2R3R4R(((s+/usr/lib64/python2.7/Demo/parser/example.pyR"XsR$cBs&eZdd„Zd„Zd„ZRS(cCs5|dd|_tj||r*|dp-dƒdS(Niiiÿÿÿÿ(R+RRR4(RR((s+/usr/lib64/python2.7/Demo/parser/example.pyR_scCs |jjƒS(N(RR-(R((s+/usr/lib64/python2.7/Demo/parser/example.pytget_method_namescscCs |j|S(N(R(RR)((s+/usr/lib64/python2.7/Demo/parser/example.pytget_method_infofsN(R2R3R4RR8R9(((s+/usr/lib64/python2.7/Demo/parser/example.pyR$^s  R cBseZddd„ZRS(scCsU||_tj||ƒ|rQtt|dƒ\}}|rQ|d|_qQndS(NiR(R+RRRRR(RRR)R%R&((s+/usr/lib64/python2.7/Demo/parser/example.pyRks  N(R2R3R4R(((s+/usr/lib64/python2.7/Demo/parser/example.pyR jscCsÒ|dkri}nt|ƒtkr?|||dsF      1   + ?