???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
¿œ^c           @   sº  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d „  Z d d d „  ƒ  YZ	 d d d „  ƒ  YZ
 d	 e	 e
 f d
 „  ƒ  YZ d e	 f d „  ƒ  YZ d e	 e
 f d „  ƒ  YZ d d „ Z e j e j d g f f Z e j e j e j e j e j e j e j e j e j e j e j e j e j e j e j  e j! e j" e j# e j$ d g f f f f f f f f f f f f f f f f f e j% d f f f Z& d S(   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(   t   ListTypet	   TupleTypec         C   sV   t  |  ƒ j ƒ  } t j j t j j |  ƒ d ƒ } t j | ƒ } 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    (
   t   opent   readt   ost   patht   basenamet   splitextt   parsert   suitet
   ModuleInfot   totuple(   t   fileNamet   sourceR   t   ast(    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_docs   s    "t   SuiteInfoBasec           B   sV   e  Z d  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   t    c         C   s,   i  |  _  i  |  _ | r( |  j | ƒ n  d  S(   N(   t   _class_infot   _function_infot   _extract_info(   t   selft   tree(    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   __init__!   s    		c         C   s  t  | ƒ d k r2 t t d | d ƒ \ } } n t t | d ƒ \ } } | rg t | d ƒ |  _ n  x¨ | d D]œ } t t | ƒ \ } } | rr | d } | d t j k rÔ | d d } t | ƒ |  j	 | <q| d t j
 k r| d d } t | ƒ |  j | <qqr qr Wd  S(   Ni   i   i   t	   docstringt   compoundi    (   t   lent   matcht   DOCSTRING_STMT_PATTERNt   evalt
   _docstringt   COMPOUND_STMT_PATTERNt   symbolt   funcdeft   FunctionInfoR   t   classdeft	   ClassInfoR   (   R   R   t   foundt   varst   nodet   cstmtt   name(    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR   '   s     
c         C   s   |  j  S(   N(   R   (   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_docstring;   s    c         C   s   |  j  S(   N(   t   _name(   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_name>   s    c         C   s   |  j  j ƒ  S(   N(   R   t   keys(   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_class_namesA   s    c         C   s   |  j  | S(   N(   R   (   R   R)   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_class_infoD   s    c         C   s/   y |  j  | SWn t k
 r* |  j | SXd  S(   N(   R   t   KeyErrorR   (   R   R)   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   __getitem__G   s    N(   t   __name__t
   __module__R   R+   t   NoneR   R   R*   R,   R.   R/   R1   (    (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR      s   					t   SuiteFuncInfoc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   |  j  j ƒ  S(   N(   R   R-   (   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_function_namesQ   s    c         C   s   |  j  | S(   N(   R   (   R   R)   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_function_infoT   s    (   R2   R3   R6   R7   (    (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR5   N   s   	R"   c           B   s   e  Z d d  „ Z RS(   c         C   s5   | d d |  _  t j |  | r* | d p- d  ƒ d  S(   Ni   i   iÿÿÿÿ(   R+   R   R   R4   (   R   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR   Y   s    N(   R2   R3   R4   R   (    (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR"   X   s   R$   c           B   s&   e  Z d d  „ Z d „  Z d „  Z RS(   c         C   s5   | d d |  _  t j |  | r* | d p- d  ƒ d  S(   Ni   i   iÿÿÿÿ(   R+   R   R   R4   (   R   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR   _   s    c         C   s   |  j  j ƒ  S(   N(   R   R-   (   R   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_method_namesc   s    c         C   s   |  j  | S(   N(   R   (   R   R)   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   get_method_infof   s    N(   R2   R3   R4   R   R8   R9   (    (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR$   ^   s   	R
   c           B   s   e  Z d d  d „ Z RS(   s   <string>c         C   sU   | |  _  t j |  | ƒ | rQ t t | d ƒ \ } } | rQ | d |  _ qQ n  d  S(   Ni   R   (   R+   R   R   R   R   R   (   R   R   R)   R%   R&   (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR   k   s    	N(   R2   R3   R4   R   (    (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR
   j   s   c         C   sÒ   | d k r i  } n  t |  ƒ t k r? | | |  d <d | f St |  ƒ t k	 ra |  | k | f St | ƒ t |  ƒ k rƒ d | f SxB t d |  | ƒ D]. \ }  } t |  | | ƒ \ } } | s– Pq– q– W| | f S(   sa  Match `data' to `pattern', with variable extraction.

    pattern
        Pattern to match against, possibly containing variables.

    data
        Data to be checked and against which variables are extracted.

    vars
        Dictionary of variables which have already been found.  If not
        provided, an empty dictionary is created.

    The `pattern' value may contain variables of the form ['varname'] which
    are allowed to match anything.  The value that is matched is returned as
    part of a dictionary which maps 'varname' to the matched value.  'varname'
    is not required to be a string object, but using strings makes patterns
    and the code which uses them more readable.

    This function returns two values: a boolean indicating whether a match
    was found and a dictionary mapping variable names to their associated
    values.
    i    i   N(   R4   t   typeR    R   R   t   mapR   (   t   patternt   dataR&   t   same(    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyR   t   s    	

R   R   R   (    (    ('   t   __doc__R   R   R    t   tokent   typesR    R   R   R   R5   R"   R$   R
   R4   R   t   stmtt   compound_stmtR   t   simple_stmtt
   small_stmtt	   expr_stmtt   testlistt   testt   and_testt   not_testt
   comparisont   exprt   xor_exprt   and_exprt
   shift_exprt
   arith_exprt   termt   factort   powert   atomt   STRINGt   NEWLINER   (    (    (    s+   /usr/lib64/python2.7/Demo/parser/example.pyt   <module>   sF   	1

+	?