???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................
Yf                 @   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)zCache 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   ./opt/alt/python35/lib64/python3.5/linecache.pyr      s    "c               C   s
   i  a  d S)zClear 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)zGet 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&    
c          "   C   s5  |  t  k r) t t  |   d k r) t  |  =|  sN |  j d  rR |  j d  rR g  S|  } y t j |  } Wn0t k
 r|  } t |  |  ry t  |  d   } Wn t t f k
 r YnL X| d k r g  St |  d d d   | j	   D | f t  |  <t  |  d St j
 j |   r!g  Sxu t j
 D]f } y t j
 j | |  } Wn t t f k
 rgw+Yn Xy t j |  } PWq+t k
 rYq+Xq+Wg  SYn Xy) t j |   } | j   } Wd QRXWn t k
 rg  SYn X| r| d
 j d	  r| d d	 7<| j | j }	 }
 |	 |
 | | f t  |  <| S)zUpdate 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.r   <>r   Nc             S   s   g  |  ] } | d   q S)
r   ).0liner   r   r   
<listcomp>q   s   	 zupdatecache.<locals>.<listcomp>r   r!   r%   )r   r   
startswithendswithr   r   r   	lazycacheImportError
splitlinespathisabssysjoin	TypeErrorAttributeErrortokenizeopen	readlinesr   r   )r	   r   r   r   basenamedatadirnamefpr   r   r   r   r   r   r   R   sV    %#			r   c             C   s   |  t  k r* t t  |   d k r& d Sd S|  sO |  j d  rS |  j d  rS d S| r d | k r | j d  } | d } t | d d	  } | r | r t j | |  } | f t  |  <d Sd S)
a  Seed the cache for filename with module_globals.

    The module loader will be asked for the source only when getlines is
    called, not immediately.

    If there is an entry in the cache already, it is not altered.

    :return: True if a lazy load is registered in the cache,
        otherwise False. To register such a load a module loader with a
        get_source method must be found, the filename must be a cachable
        filename, and the filename must not be already cached.
    r   TFr   r    
__loader____name__
get_sourceN)r   r   r&   r'   getgetattr	functoolspartial)r	   r   nameloaderr:   	get_linesr   r   r   r(      s    %
r(   )__doc__r=   r-   r   r1   __all__r   r   r   r   r   r   r(   r   r   r   r   <module>   s   A