ó
`¾Tc           @   sH   d  Z  d d l Z d d l Z d d l m Z d e f d „  ƒ  YZ d S(   s§  
    flask.exthook
    ~~~~~~~~~~~~~

    Redirect imports for extensions.  This module basically makes it possible
    for us to transition from flaskext.foo to flask_foo without having to
    force all extensions to upgrade at the same time.

    When a user does ``from flask.ext.foo import bar`` it will attempt to
    import ``from flask_foo import bar`` first and when that fails it will
    try to import ``from flaskext.foo import bar``.

    We're switching from namespace packages because it was just too painful for
    everybody involved.

    This is used by `flask.ext`.

    :copyright: (c) 2011 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
iÿÿÿÿNi   (   t   reraiset   ExtensionImporterc           B   sY   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d	 d „ Z d „  Z	 d „  Z
 d „  Z RS(
   sÏ   This importer redirects imports from this submodule to other locations.
    This makes it possible to transition from the old flaskext.name to the
    newer flask_name without people having a hard time.
    c         C   s9   | |  _  | |  _ | d |  _ | j d ƒ d |  _ d  S(   Nt   .i   (   t   module_choicest   wrapper_modulet   prefixt   countt   prefix_cutoff(   t   selfR   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   __init__!   s    		c         C   sR   |  j  j | j  j k oQ |  j  j | j  j k oQ |  j | j k oQ |  j | j k S(   N(   t	   __class__t
   __module__t   __name__R   R   (   R   t   other(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   __eq__'   s    c         C   s   |  j  | ƒ S(   N(   R   (   R   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   __ne__-   s    c         C   s7   g  t  j D] } |  | k r
 | ^ q
 |  g t  j (d  S(   N(   t   syst	   meta_path(   R   t   x(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   install0   s    c         C   s   | j  |  j ƒ r |  Sd  S(   N(   t
   startswithR   (   R   t   fullnamet   path(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   find_module3   s    c   	      C   s  | t  j k r t  j | S| j d |  j ƒ |  j } xÒ |  j D]Ç } | | } y t | ƒ Wnd t k
 rÄ t  j ƒ  \ } } } t  j j | d  ƒ |  j
 | | ƒ r@ t | | | j ƒ q@ q@ n Xt  j | } t  j | <d | k rt t  j |  j | | ƒ n  | SWt d | ƒ ‚ d  S(   NR   s   No module named %s(   R   t   modulest   splitR   R   t
   __import__t   ImportErrort   exc_infot   popt   Nonet   is_important_tracebackR    t   tb_nextt   setattrR   (	   R   R   t   modnameR   t   realnamet   exc_typet	   exc_valuet   tbt   module(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   load_module7   s$    
c         C   s6   x/ | d k	 r1 |  j | | ƒ r% t S| j } q Wt S(   s-  Walks a traceback's frames and checks if any of the frames
        originated in the given important module.  If that is the case then we
        were able to import the module itself but apparently something went
        wrong when the module was imported.  (Eg: import of an import failed).
        N(   R   t   is_important_framet   TrueR    t   False(   R   t   important_moduleR&   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyR   Y   s
    c         C   s›   | j  j } d | k r t S| d } | | k r6 t St j j | j  j j ƒ } t j j	 | j
 d t j j	 ƒ } | d | k pš | t j j	 d | k S(   s(   Checks a single frame if it's important.R   R   s   .pys   __init__.py(   t   tb_framet	   f_globalsR+   R*   t   osR   t   abspatht   f_codet   co_filenamet   sept   replace(   R   R,   R&   t   gt   module_namet   filenamet   test_string(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyR)   e   s    
"N(   R   R   t   __doc__R	   R   R   R   R   R   R(   R   R)   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyR      s   					"	(   R9   R   R/   t   _compatR    t   objectR   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/exthook.pyt   <module>   s   