f`dZddlZddlZddlZddlZgdZiZdZd dZd dZ d dZ d dZ d Z y) 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,tjy)zClear the cache entirely.N)cacheclear /usr/lib/python3.12/linecache.pyrrs  KKMr cZt||}d|cxkrt|kr ny||dz Sy)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_globalsliness r rrs8 X~ .EF c%j VaZ  r c|tvr#t|}t|dk7r t|dS t||S#t$rt gcYSwxYw)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)rr updatecache MemoryErrorr)rrentrys r rr$sZ5h u:??1% %8^44   s 9AAc|ttj}n |tvr|g}ny|D]o}t|}t|dk(r|\}}}}|% t j |}||jk7s||jk7sZtj|dqy#t $rtj|dYwxYw)zUDiscard cache entries that are out of date. (This is not checked upon each call!)Nr) listrkeysrosstatOSErrorpopst_sizest_mtime)r filenamesrsizemtimerfullnamers r rr4s& U J &h u:? ',$eUH =  778$D 4<< 5DMM#9 IIh %&  IIh %  sB##CCc|tvr+tt|dk7rtj|d|r"|jdr|j drgS|} t j |} t#j$|5}|j'} ddd r!| dj ds | dxxdz cc<|j,|j.} } | | | |ft|<| S#t$r |}t||ru t|d}|gcYSt|d|jDcgc]}|dz ncc}wc}|ft|<t|dcYS#ttf$rYnwxYwt jj|rgcYStjD]_} t jj||}n#tt f$rY6wxYw t j |}n#t$rY]wxYwgcYSYwxYw#1swYxYw#tt(t*f$rgcYSwxYw) 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.rN<>r r)rrr! startswithendswithrrr r splitlines ImportErrorpathisabssysjoin TypeErrorAttributeErrortokenizeopen readlinesUnicodeDecodeError SyntaxErrorr"r#) rrr'rbasenamedatalinedirnamefprr%r&s r rrPs5 5 uX 1 $ IIh % ++C0X5F5Fs5K H*wwx T ]]8 $ #LLNE # U2Y''- b T ,, %DE5(2E(O Le ( X~ . *Xq)+<II-1__->?TTD[?? #h Xq)) )  " 77== "Ixx G 77<<:~.   wwx(   I I(T # # ' 5 sC+3H%HH%+HE#HH7 E H#E52H4E55$HH/ GHG"H!G""H&G=;H= H HH  HHH"H%%H>=H>c|tvrtt|dk(ryy|r"|jdr|jdry|r{d|vrw|j d}t |dd xs|d}t |d d }||j d }t |d d }|r#|r!t j||}|ft|<yy) aSeed 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. rTFr)r*__name____spec__nameNloader __loader__ get_source)rrr-r.getgetattr functoolspartial)rrspecrDrErG get_liness r rrs5 uX 1 $ ++C0X5F5Fs5K*6!!*-tVT*HnZ.Hx. >#'' 5FV\48 J!))*d;I(lE(O r )N) __doc__rJr3rr7__all__rrrrrrrr r r rPsD  >    &8@F!r