
    F\ht                     d    S r / SQr0 r0 rS rSS jrSS jrS rS rS 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/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                 Z    [        U 5      nSUs=::  a  [        U5      ::  a
  O  gX!S-
     $ g)Nr   r   )_getlines_from_coder   )r   r   r   s      r   _getline_from_coder   0   s2    )EF c%j  aZ  r
   c                 H    U R                   U R                  U R                  4$ N)co_filenameco_qualnameco_firstlineno)codes    r   	_make_keyr#   6   s!    d..0C0CDDr
   c                 x    [        U 5      nU[        ;   a$  [        U   n[        U5      S:w  a  [        U   S   $ / $ )Nr   r   )r#   _interactive_cacher   )r"   code_idr   s      r   r   r   9   s>    oG$$"7+u:?%g.q11Ir
   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   B   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$ ! [         a    / s $ f = f! [         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   r1   
startswithendswithr.   r/   r   
splitlinespathisabsjoin	TypeErrorAttributeErrorr0   open	readlinesUnicodeDecodeErrorSyntaxErrorr2   r3   )r   r   r,   r=   r>   r7   r.   basenamedatalinedirnamefpr   r5   r6   s                  r   r   r   f   se   
 5uX1$IIh%++C00X5F5Fs5K5K	H,wwx X]]8$LLNE % 2Y%%b	T	,,%52E(OLG  	  ( X..*Xq)+ < II-1__->?->TD[->?	#h Xq))  ) " 77==""IxxG77<<:~. wwx(Z(    I 	 %$'5 	s   D <D I4 I"0I4 DDI=F II2F
 I F30I2F33%II*HIHIHIH4/I4IIIIII"
I1,I4 1I4 4JJ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   TFr9   r:   __name____spec__nameNloader
__loader__
get_sourcec                    > T" U /UQ70 UD6$ r   r	   )rS   argskwargsrV   s      r   	get_lineslazycache.<locals>.get_lines   s    !$8888r
   )r   r   r?   r@   getgetattr)r   r   specrS   rT   rZ   rV   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                 Z   [        U5      S UR                  5        Vs/ s H  o3S-   PM	     snU4nU /nU(       al  UR                  5       n U R                   H0  n[	        U[        U 5      5      (       d  M  UR                  U5        M2     U[        [        U 5      '   U(       a  Mk  g g s  snf )Nr;   )	r   rA   r1   	co_consts
isinstancetypeappendr%   r#   )r"   stringrS   rM   r   stackconsts          r   _register_coderg      s    [&,&7&7&9:&9dTk&9:E FE
yy{^^E%d,,U# $ /49T?+ % ;s   B(r   )__doc____all__r   r%   r   r   r   r   r#   r   r   r   r   rg   r	   r
   r   <module>rj      sU    ?
 	 
 E!&HOd"H4r
   