ó
xFWgc           @   sÑ   d  Z  d d l m Z m Z d „  Z d d d „  ƒ  YZ d d d „  ƒ  YZ d „  Z e d	 k rÍ d d
 l	 Z	 d d l m
 Z
 m Z xH e	 j d D]6 Z e GHe
 e ƒ Z e ƒ  Z e e e ƒ e j GHHq Wn  d
 S(   s   Parser for future statements

iÿÿÿÿ(   t   astt   walkc         C   s1   t  |  t j ƒ s d S|  j d k r) d Sd Sd S(   s:   Return true if statement is a well-formed future statementi    t
   __future__i   N(   t
   isinstanceR    t   Fromt   modname(   t   stmt(    (    s%   /usr/lib/python2.7/compiler/future.pyt	   is_future   s
    t   FutureParserc           B   s2   e  Z d Z d „  Z d „  Z d	 „  Z d
 „  Z RS(   t   nested_scopest
   generatorst   divisiont   absolute_importt   with_statementt   print_functiont   unicode_literalsc         C   s   i  |  _  d  S(   N(   t   found(   t   self(    (    s%   /usr/lib/python2.7/compiler/future.pyt   __init__   s    c         C   s4   | j  } x$ | j D] } |  j | ƒ s Pq q Wd  S(   N(   t   nodet   nodest
   check_stmt(   R   R   R   t   s(    (    s%   /usr/lib/python2.7/compiler/future.pyt   visitModule   s    	c         C   sc   t  | ƒ r_ xC | j D]8 \ } } | |  j k rA d |  j | <q t d | ‚ q Wd | _ d Sd S(   Ni   s    future feature %s is not definedi    (   R   t   namest   featuresR   t   SyntaxErrort   valid_future(   R   R   t   namet   asname(    (    s%   /usr/lib/python2.7/compiler/future.pyR      s    	c         C   s   |  j  j ƒ  S(   s4   Return list of features enabled by future statements(   R   t   keys(   R   (    (    s%   /usr/lib/python2.7/compiler/future.pyt   get_features+   s    (   R	   R
   R   R   R   R   R   (   t   __name__t
   __module__R   R   R   R   R   (    (    (    s%   /usr/lib/python2.7/compiler/future.pyR      s     			t   BadFutureParserc           B   s   e  Z d  Z d „  Z RS(   s#   Check for invalid future statementsc         C   s=   t  | d ƒ r d  S| j d k r& d  St d t | ƒ ‚ d  S(   NR   R   s   invalid future statement (   t   hasattrR   R   t   repr(   R   R   (    (    s%   /usr/lib/python2.7/compiler/future.pyt	   visitFrom2   s
    (   R    R!   t   __doc__R%   (    (    (    s%   /usr/lib/python2.7/compiler/future.pyR"   /   s   c         C   s6   t  ƒ  } t ƒ  } t |  | ƒ t |  | ƒ | j ƒ  S(   N(   R   R"   R   R   (   R   t   p1t   p2(    (    s%   /usr/lib/python2.7/compiler/future.pyt   find_futures9   s
    		t   __main__N(   t	   parseFileR   i   (    (    (   R&   t   compilerR    R   R   R   R"   R)   R    t   sysR+   t   argvt   filet   treet   vR   (    (    (    s%   /usr/lib/python2.7/compiler/future.pyt   <module>   s   		
		