B M��j��@sndZddlZddlZddlZddlZdddgZddd�Ziadd�Zddd �Z dd d�Z dd d �Z d d�Z dS)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� checkcachecCs:t||�}d|kr"t|�kr2nn ||dSdSdS)N��)�getlines�len)�filename�lineno�module_globals�lines�r �./opt/alt/python37/lib64/python3.7/linecache.pyrs  cCsiadS)zClear the cache entirely.N)�cacher r r rrscCsR|tkr(t|}t|�dkr(t|dSy t||�Stk rLt�gSXdS)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)rr� updatecache� MemoryErrorr)r r �entryr r rr%s   rc Cs�|dkrtt���}n|tkr&|g}ndSx�|D]�}t|}t|�dkrJq0|\}}}}|dkr`q0yt�|�}Wn"tk r�t�|d�w0YnX||jks�||j kr0t�|d�q0WdS)zUDiscard cache entries that are out of date. (This is not checked upon each call!)Nr) �listr�keysr�os�stat�OSError�pop�st_size�st_mtime)r � filenamesr�size�mtimer �fullnamerr r rr5s&    c Cs�|tkr$tt|�dkr$t�|d�|r<|�d�r@|�d�r@gS|}yt�|�}W�ntk �rZ|}t||�r�yt|d�}Wnt tfk r�Yn<X|dkr�gSt|�ddd�|� �D�|ft|<t|dStj � |�r�gSxjt j D]\}ytj �||�}Wnttfk �r$w�YnXyt�|�}PWq�tk �rLYq�Xq�WgSYnXy"t�|��}|��}WdQRXWntk �r�gSX|�r�|d �d ��s�|d d 7<|j|j} } | | ||ft|<|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.rN�<�>rcSsg|] }|d�qS)� r )�.0�liner r r� <listcomp>qszupdatecache.<locals>.<listcomp>r���r")rrr� startswith�endswithrrr� lazycache� ImportError� splitlines�path�isabs�sys�join� TypeError�AttributeError�tokenize�open� readlinesrr) r r rr�basename�data�dirname�fpr rrr r rrRsV         rcCs�|tkr tt|�dkrdSdS|r8|�d�r<|�d�r<dS|r�d|kr�|�d�}|d}t|dd �}|r�|r�t�||�}|ft|<dSdS) 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. rTFr r!� __loader__�__name__� get_sourceN)rrr'r(�get�getattr� functools�partial)r r �name�loaderr;� get_linesr r rr)�s      r))N)N)N)N) �__doc__r>r.rr2�__all__rrrrrrr)r r r r�<module>s     A