
    ѝi@                     j    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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     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                     [         R                  U S5      nUb  [        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.Nr      )r   getr   updatecacheMemoryErrorr   )r   r   entrys      r   r   r       sV     IIh%ESZ1_Qx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   /   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$   5   s!    d..0C0CDDr
   c                 v    [        U 5      n[        R                  US 5      nUb  [        U5      S:w  a  US   $ / $ )Nr   r   )r$   _interactive_cacher   r   )r#   code_idr   s      r   r   r   8   s;    oG""7D1ESZ1_QxIr
   c                    U c#  [         R                  5       R                  5       nOU /nU H  n [         R                  U S5      nUb  [	        U5      S:X  a  M-  Uu  p4pVUc  M7   SSKn UR                  U5      nX8R                  :w  d  XHR                  :w  d  Mn  [         R                  U S5        M     g! [         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keysr   r   osImportErrorstatOSError
ValueErrorpopst_sizest_mtime)	r   	filenamesr   sizemtimer   fullnamer,   r.   s	            r   r   r   @   s     JJL%%'	J			(D)=CJ!O',$U=		778$D <<5MM#9IIh%'   		 $ 	IIh%	s$   $B5)C5
CC&C0/C0c                     SSK nSSKnSSKn[        R                  U S5      n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                  nnUUX4[        U '   U$ ! [         a    / s $ f = f! [         Ga3    U nUb  [        U5      S:X  a  UOSn	U	c  [        X5      n	U	bn   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nU[        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)   N<>r   
r   )r,   systokenizer-   r   r1   
startswithendswithr.   r/   r   _make_lazycache_entry
splitlinespathisabsjoin	TypeErrorAttributeErrorr0   open	readlinesUnicodeDecodeErrorSyntaxErrorr2   r3   )r   r   r,   r=   r>   r   r7   r.   basename
lazy_entrydatalinedirnamefpr   r5   r6   s                    r   r   r   `   sl   
 IIh%E++C00X5F5Fs5K5K	H0wwx `]]8$LLNE % 2Y%%b	T	,,%DE52E(OLK  	  , $/CJ!OU
.xHJ! !!} < II-1__->?->TD[->?	 #(hQx  ) $ 77==""IxxG77<<:~. wwx(Z(    I 	 %$'5 	s   C/ D .I! ?II! /C>=C>4I6
F II$E3
2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                     [         R                  U S5      nUb  [        U5      S:H  $ [        X5      nUb
  U[         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.
Nr   TF)r   r   r   rA   )r   r   r   rM   s       r   r   r      sG     IIh%E5zQ&x@J$hr
   c                 l  ^ U (       a,  U R                  S5      (       a  U R                  S5      (       a  g U(       ax  SU;   ar  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$ g )
Nr9   r:   __name____spec__nameloader
__loader__
get_sourcec                    > T" U /UQ70 UD6$ r   r	   )rV   argskwargsrY   s      r   	get_lines(_make_lazycache_entry.<locals>.get_lines   s    !$8888r
   )r?   r@   r   getattr)r   r   specrV   rW   r]   rY   s         @r   rA   rA      s    ++C00X5F5Fs5K5K*6!!*-tVT*HnZ.Hx.>#''5FV\48
J# 9<r
   c                 ^   [        U5      S UR                  5        Vs/ s H  o3S-   PM	     snU4nU /nU(       an  UR                  5       n U R                   H0  n[	        U[        U 5      5      (       d  M  UR                  U5        M2     [        U 5      nU[        U'   U(       a  Mm  g g s  snf )Nr;   )	r   rB   r1   	co_consts
isinstancetypeappendr$   r&   )r#   stringrV   rO   r   stackconstkeys           r   _register_coderj      s    [&,&7&7&9:&9dTk&9:E FE
yy{^^E%d,,U# $ o"'3 % ;s   B*r   )__doc____all__r   r&   r   r   r   r   r$   r   r   r   r   rA   rj   r	   r
   r   <module>rm      sY    ?
 	 
E&@Qh0((r
   