
    >:g                     N    S r / SQr0 rS rS
S jrS
S jrS
S jrS
S jrS rS	 r	g)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.
)getline
clearcache
checkcache	lazycachec                  ,    [         R                  5         g)zClear the cache entirely.N)cacheclear     &/usr/local/lib/python3.13/linecache.pyr   r      s    	KKMr
   Nc                 Z    [        X5      nSUs=::  a  [        U5      ::  a
  O  gX1S-
     $ g)zzGet a line for a Python source file from the cache.
Update the cache if it doesn't contain an entry for this file already.    )getlineslen)filenamelinenomodule_globalsliness       r   r   r      s4     X.EF c%j  aZ  r
   c                     U [         ;   a$  [         U    n[        U5      S:w  a  [         U    S   $  [        X5      $ ! [         a    [	        5         / s $ f = f)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      )r   r   updatecacheMemoryErrorr   )r   r   entrys      r   r   r      sX     5hu:??1%%844 	s   
; AAc                    U c#  [         R                  5       R                  5       nOU /nU Hu  n  [         U    n[	        U5      S:X  a  M  Uu  p4pVUc  M(   SSKn UR                  U5      nX8R                  :w  d  XHR                  :w  d  M_  [         R                  U S5        Mw     g! [         a     M  f = f! [         a       gf = f! [        [        4 a    [         R                  U S5         M  f = f)zQDiscard cache entries that are out of date.
(This is not checked upon each call!)Nr       )r   copykeysKeyErrorr   osImportErrorstatOSError
ValueErrorpopst_sizest_mtime)	r   	filenamesr   sizemtimer   fullnamer   r!   s	            r   r   r   /   s     JJL%%'	J		(OE u:?',$U=		778$D <<5MM#9IIh%/   		  		 $ 	IIh%	s5   	B&B7C&
B43B47
CC&C21C2c                    SSK nSSKnSSKnU [        ;   a,  [	        [        U    5      S:w  a  [        R                  U S5        U (       a,  U R                  S5      (       a  U R                  S5      (       a  / $ U n UR                  U5      n UR'                  U5       nUR)                  5       nSSS5        W(       d  S/nO&US   R                  S5      (       d  US==   S-  ss'   UR.                  UR0                  pXX4[        U '   U$ ! [         Ga(    U n[        X5      (       az   [        U    S   " 5       nUc  / s $ [	        U5      SUR                  5        V	s/ s H  oS-   PM	     Os  sn	f sn	U4[        U '   [        U    S   s $ ! [        [        4 a     Of = fUR                  R                  U 5      (       a  / s $ UR                   Hc  n
 UR                  R                  X5      nO! [         ["        4 a     M3  f = f UR                  U5      n   GM  ! [        [$        4 a     Ma  f = f   / s $ [$         a    / s $ f = f! , (       d  f       GN= f! [        [*        [,        4 a    / s $ f = f)	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   Nr   <>
r   )r   systokenizer   r   r$   
startswithendswithr!   r"   r   
splitlinesr    pathisabsjoin	TypeErrorAttributeErrorr#   open	readlinesUnicodeDecodeErrorSyntaxErrorr%   r&   )r   r   r   r0   r1   r*   r!   basenamedatalinedirnamefpr   r(   r)   s                  r   r   r   S   sK    5uX1$IIh%++C00X5F5Fs5K5K	H,wwx X]]8$LLNE % 2Y%%b	T	,,%52E(OLm  ( X..*Xq)+ < II-1__->?->TD[->?	#h Xq))  ) " 77==""IxxG77<<:~. wwx(Z(    I 	 %$'5 	s   ;D I! I/I! I*F;IIE.
-IF IF  %IIG32I3HIHIH!I!H51I4H55I>II
II! I! !I;:I;c                   ^ U [         ;   a  [        [         U    5      S:X  a  ggU (       a,  U R                  S5      (       a  U R                  S5      (       a  gU(       a  SU;   az  UR	                  S5      n[        USS	5      =(       d    US   n[        US
S	5      nUc  UR	                  S5      n[        USS	5      mU(       a  T(       a  U4U4S jjnU4[         U '   gg)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 cacheable
    filename, and the filename must not be already cached.
r   TFr,   r-   __name____spec__nameNloader
__loader__
get_sourcec                    > T" U /UQ70 UD6$ Nr	   )rF   argskwargsrI   s      r   	get_lineslazycache.<locals>.get_lines   s    !$8888r
   )r   r   r2   r3   getgetattr)r   r   specrF   rG   rN   rI   s         @r   r   r      s     5uX1$++C00X5F5Fs5K5K*6!!*-tVT*HnZ.Hx.>#''5FV\48
J# 9(lE(Or
   c                 |    [        U5      S UR                  5        Vs/ s H  o3S-   PM	     snU4[        U '   g s  snf )Nr.   )r   r4   r   )codestringrF   r@   s       r   _register_coderV      s>    K%+%6%6%89%8TD[%89	E$K :s   9rK   )
__doc____all__r   r   r   r   r   r   r   rV   r	   r
   r   <module>rY      s?    ?
 	
 !&HK\"Jr
   