o
`wi: @ sl d Z ddlZddlZddlZddlZg dZi Zdd ZdddZddd Z dd
dZ
ddd
Zdd ZdS )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
checkcache lazycachec C s t dS )zClear the cache entirely.N)cacheclear r r /usr/lib/python3.10/linecache.pyr s r c C s8 t | |}d| krt|krn dS ||d S dS )z~Get a line for a Python source file from the cache.
Update the cache if it doesn't contain an entry for this file already. )getlineslen)filenamelinenomodule_globalslinesr r r r s
r c C sR | t v rt | }t|dkrt | d S zt| |W S ty( t g Y S w )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
)r r
updatecacheMemoryErrorr )r r entryr r r r $ s r c C s | du rt t }n
| tv r| g}ndS |D ]?} t| }t|dkr$q|\}}}}|du r/qzt|}W n tyE t| d Y qw ||jksP||j krVt| d qdS )zUDiscard cache entries that are out of date.
(This is not checked upon each call!)Nr
)
listr keysr
osstatOSErrorpopst_sizest_mtime)r filenamesr sizemtimer fullnamer r r r r 4 s, r c
C s | t v rtt | dkrt | d | r| dr | dr g S | }zt|}W n ty | }t| |rmz t | d }W n t tfyK Y n"w |du rTg Y S t|ddd |
D |ft | <