ó
5Ž	Pc           @   sp   d  Z  d d l Z d d l Z d d d g Z d d  Z i  a d   Z d d  Z d d	  Z	 d d
  Z
 d S(   sµ   Cache lines from files.

This is intended to read lines from modules imported -- hence if a filename
is not found, it will look down the module search path for a file by
that name.
i’’’’Nt   getlinet
   clearcachet
   checkcachec         C   sE   t  |  |  } d | k o, t |  k n r= | | d Sd Sd  S(   Ni   t    (   t   getlinest   len(   t   filenamet   linenot   module_globalst   lines(    (    s   /usr/lib/python2.7/linecache.pyR       s    "c           C   s
   i  a  d S(   s   Clear the cache entirely.N(   t   cache(    (    (    s   /usr/lib/python2.7/linecache.pyR      s    c         C   s)   |  t  k r t  |  d St |  |  Sd S(   ss   Get the lines for a file from the cache.
    Update the cache if it doesn't contain an entry for this file already.i   N(   R
   t   updatecache(   R   R   (    (    s   /usr/lib/python2.7/linecache.pyR   !   s    c         C   sŠ   |  d k r t j   } n |  t k r3 |  g } n d Sx | D] }  t |  \ } } } } | d k rl q> n  y t j |  } Wn t j k
 r t |  =q> n X| | j k s¾ | | j k r> t |  =q> q> Wd S(   sU   Discard cache entries that are out of date.
    (This is not checked upon each call!)N(   t   NoneR
   t   keyst   ost   statt   errort   st_sizet   st_mtime(   R   t	   filenamest   sizet   mtimeR	   t   fullnameR   (    (    s   /usr/lib/python2.7/linecache.pyR   +   s     c         C   s{  |  t  k r t  |  =n  |  s; |  j d  r? |  j d  r? g  S|  } y t j |  } Wnt k
 rć|  } | r<d | k r<| j d  } | d } t | d d
  } | r<| r<y | |  } Wn t	 t
 f k
 rą q9X| d
 k rń g  St |  d
 g  | j   D] }	 |	 d ^ q
| f t  |  <t  |  d Sq<n  t j j |   rRg  S| d k rg|  } n  xz t j D]g }
 y t j j |
 |  } Wn t t f k
 r¬qqn Xy t j |  } PWqqt j k
 r×qqXqqWg  Sn Xy( t | d	   } | j   } Wd
 QXWn t
 k
 r g  SX| rN| d j d  rN| d c d 7<n  | j | j } } | | | | f t  |  <| S(   s   Update a cache entry and return its list of lines.
    If something's wrong, print a message, discard the cache entry,
    and return an empty list.t   <t   >t
   __loader__t   __name__t
   get_sources   
i   s   __init__.pyt   rUNi’’’’(   R
   t
   startswitht   endswithR   R   t   OSErrort   gett   getattrR   t   ImportErrort   IOErrorR   t
   splitlinest   patht   isabst   syst   joint	   TypeErrort   AttributeErrorR   t   opent	   readlinesR   R   (   R   R   R   R   t   basenamet   namet   loaderR   t   datat   linet   dirnamet   fpR	   R   R   (    (    s   /usr/lib/python2.7/linecache.pyR   D   s`    
%
-	(   t   __doc__R'   R   t   __all__R   R    R
   R   R   R   R   (    (    (    s   /usr/lib/python2.7/linecache.pyt   <module>   s   
	
