
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \À  ã               @   sn   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   s:   t | |ƒ}d|  ko t|ƒkn  r2||d  S dS d S )Né   Ú )ÚgetlinesÚlen)ÚfilenameÚlinenoÚmodule_globalsÚlines© r   ú!/usr/lib64/python3.6/linecache.pyr      s    
c               C   s   i a dS )zClear the cache entirely.N)Úcacher   r   r   r   r      s    c             C   sR   | t kr(t |  }t|ƒdkr(t |  d S y
t| |ƒS  tk
rL   tƒ  g S X d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r&| g}ndS x~|D ]v} t|  }t|ƒdkrJq0|\}}}}|dkr`q0ytj|ƒ}W n tk
rŠ   t| = w0Y nX ||jks ||jkr0t| = q0W d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   sÜ  | t krtt |  ƒdkrt | = |  s8| jdƒr<| jdƒr<g S | }ytj|ƒ}W �n tk
�rV   | }t| |ƒrÖyt |  d ƒ }W n ttfk
rš   Y n<X |dkr¨g S t|ƒddd„ |j	ƒ D ƒ|ft | < t |  d S tj
j| ƒræg S xjtj
D ]\}ytj
j||ƒ}W n ttfk
�r    wîY nX ytj|ƒ}P W qî tk
�rH   Y qîX qîW g S Y nX y"tj|ƒ�}|jƒ }W dQ R X W n tk
�r�   g S X |�rº|d
 jd	ƒ �rº|d  d	7  < |j|j }	}
|	|
||ft | < |S )z”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.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S dS |  s:| jdƒr>| jdƒr>dS |rŠd|krŠ|jdƒ}|d }t|dd	ƒ}|rŠ|rŠtj||ƒ}|ft | < dS d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(   )N)N)N)N)Ú__doc__r=   r-   r   r1   Ú__all__r   r   r   r   r   r   r(   r   r   r   r   Ú<module>   s   




A