mò
­fIc           @   sa   d  Z  d k Z d k Z d d d g Z d   Z h  a d   Z d   Z d d  Z	 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.
Nt   getlinet
   clearcachet
   checkcachec         C   sH   t  |   } d | j o t |  j n o | | d Sn d Sd  S(   Ni   t    (   t   getlinest   filenamet   linest   linenot   len(   R   R   R   (    (    t&   /mit/python/lib/python2.4/linecache.pyR       s    $c           C   s
   h  a  d S(   s   Clear the cache entirely.N(   t   cache(    (    (    R	   R      s      c         C   s+   |  t j o t |  d Sn t |   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   R
   t   updatecache(   R   (    (    R	   R   !   s     c         C   sÇ   |  d j o t i   } n |  t j o |  g } n d Sx | D]} }  t |  \ } } } } y t	 i
 |  } Wn  t	 i j
 o t |  =qB n X| | i j p | | i j o t |  =qB qB Wd S(   sU   Discard cache entries that are out of date.
    (This is not checked upon each call!)N(   R   t   NoneR
   t   keyst	   filenamest   sizet   mtimeR   t   fullnamet   ost   statt   errort   st_sizet   st_mtime(   R   R   R   R   R   R   R   (    (    R	   R   +   s        c   
      C   sw  |  t j o t |  =n |  p |  d |  d d j o g  Sn |  } y t i |  } Wn¨ t i j
 o } t i i |   d } x| t
 i D]h } y t i i | |  } Wn t t f j
 o q Xy t i |  } PWq t i j
 o q Xq Wg  Sn Xy) t | d  } | i   } | i   Wn t j
 o } g  Sn X| i | i }	 } |	 | | | 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.i    i˙˙˙˙s   <>i   t   rUN(   R   R
   R   R   R   R   t   msgt   patht   splitt   basenamet   syst   dirnamet   joint	   TypeErrort   AttributeErrort   opent   fpt	   readlinesR   t   closet   IOErrorR   R   R   R   (
   R   R"   R   R   R   R   R   R   R   R   (    (    R	   R   B   s>     !
 			(   t   __doc__R   R   t   __all__R    R
   R   R   R   R   R   (   R   R   R'   R   R   R   R   R    (    (    R	   t   ?   s   			
		
