File: //proc/thread-self/root/usr/lib/python3.5/__pycache__/linecache.cpython-35.pyc
��j`�  �               @   s�   d  Z  d d l Z d d l Z d d l Z d d l Z d d d g Z d d d � Z i  a d d �  Z d d d	 � Z	 d d
 d � Z
 d d d � Z d
 d �  Z d S)z�Cache lines from Python source 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.
�    N�getline�
clearcache�
checkcachec             C   sE   t  |  | � } d | k o, t | � k n r= | | d Sd Sd  S)N�   � )�getlines�len)�filename�lineno�module_globals�lines� r
   �/usr/lib/python3.5/linecache.pyr      s    "c               C   s
   i  a  d S)zClear the cache entirely.N)�cacher
   r
   r
   r   r      s    c             C   si   |  t  k r4 t  |  } t | � d k r4 t  |  d Sy t |  | � SWn t k
 rd t �  g  SYn Xd S)z�Get the lines for a Python source file from the cache.
    Update the cache if it doesn't contain an entry for this file already.r   �   N)r   r   �updatecache�MemoryErrorr   )r	   r   �entryr
   r
   r   r   %   s    
r   c             C   s�   |  d k r! t  t j �  � } n |  t k r9 |  g } n d Sx� | D]� }  t |  } t | � d k ri qD | \ } } } } | d k r� qD y t j | � } Wn t k
 r� t |  =wD Yn X| | j k s� | | j k rD t |  =qD Wd S)zUDiscard cache entries that are out of date.
    (This is not checked upon each call!)Nr   )	�listr   �keysr   �os�stat�OSError�st_size�st_mtime)r	   �	filenamesr   �size�mtimer   �fullnamer   r
   r
   r   r   5   s&