ó õ^‚Rc@sídZddlZddlZddlZddlmZmZmZddlm Z ddddgZ iZ ddd „ƒYZ ddd „ƒYZ dd „Zdd „Zdd „Zd„Zd„Zd„ZedkréeƒndS(sçParse a Python module and describe its classes and methods. Parse enough of a Python file to recognize imports and class and method definitions, and to find out the superclasses of a class. The interface consists of a single function: readmodule_ex(module [, path]) where module is the name of a Python module, and path is an optional list of directories where the module is to be searched. If present, path is prepended to the system search path sys.path. The return value is a dictionary. The keys of the dictionary are the names of the classes defined in the module (including classes that are defined via the from XXX import YYY construct). The values are class instances of the class Class defined here. One special key/value pair is present for packages: the key '__path__' has a list as its value which contains the package search path. A class is described by the class Class in this module. Instances of this class have the following instance variables: module -- the module name name -- the name of the class super -- a list of super classes (Class instances) methods -- a dictionary of methods file -- the file in which the class was defined lineno -- the line in the file on which the class statement occurred The dictionary of methods uses the method names as keys and the line numbers on which the method was defined as values. If the name of a super class is not recognized, the corresponding entry in the list of super classes is not a class instance but a string giving the name of the super class. Since import statements are recognized and imported modules are scanned as well, this shouldn't happen often. A function is described by the class Function in this module. Instances of this class have the following instance variables: module -- the module name name -- the name of the class file -- the file in which the class was defined lineno -- the line in the file on which the class statement occurred iÿÿÿÿN(tNAMEtDEDENTtOP(t itemgettert readmodulet readmodule_extClasstFunctioncBs eZdZd„Zd„ZRS(s"Class to represent a Python class.cCsO||_||_|dkr'g}n||_i|_||_||_dS(N(tmoduletnametNonetsupertmethodstfiletlineno(tselfRR R R R((s/usr/lib/python2.7/pyclbr.pyt__init__7s       cCs||j|x7|D]/\}}}}}|tkr\|\}}xÿ|rX|dd|krX|d=q4Wq|d kr2|\}}x%|r›|dd|kr›|d=qwW|jƒdd !\}}}|tkrÊqn|r|dd}t|tƒr|j||ƒqnt||| |ƒ||<|jd|fƒq|d krž|\}}x%|rq|dd|krq|d=qMW|jƒdd !\}}}|tkr qn|jƒdd !\}}}d}|d kr]g}d}g}xqtrS|jƒdd !\}}}|dkrÅ|dkrÅdj|ƒ}||krE||}nj|jdƒ}t|ƒdkr¯|d} |d}| tkr¯t| }!||!kr¬|!|}q¬q¯n|j|ƒg}n|d krÞ|d7}qã|d kr|d8}|dkrPPqPqã|dkr"|dkr"qã|ttfkrã|dkrã|j|ƒqãqãW|}nt|||| |ƒ}|sˆ|||KsRRRs defR(tosR)targvRtexiststdirnametbasenametlowertendswithRtvaluestsortRRR R RtsortedR t iteritemsRR( RiR^RRAtobjstobjR R R((s/usr/lib/python2.7/pyclbr.pyt_main>s(    ! t__main__(((RR)R.R3RNRRRtoperatorRt__all__R(RRR RRRR<R=RvR(((s/usr/lib/python2.7/pyclbr.pyt(s"    ¶