a DOgU@sldZddlZddlZddlZddlZgdZiZddZdddZddd Z dd d Z dd d Z ddZ dS)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 lazycachecCs tdS)zClear the cache entirely.N)cacheclearrr./opt/alt/python39/lib64/python3.9/linecache.pyrsrcCs6t||}d|kr"t|kr2nn ||dSdS)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_globalslinesrrr rs  rcCsV|tvr(t|}t|dkr(t|dSz t||WStyPtgYS0dS)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 N)rr updatecache MemoryErrorr)rrentryrrr r $s    r c Cs|durtt}n|tvr&|g}ndS|D]}t|}t|dkrHq.|\}}}}|dur^q.zt|}Wn"tyt|dYq.Yn0||jks||j kr.t|dq.dS)zUDiscard cache entries that are out of date. (This is not checked upon each call!)Nr ) listrkeysr osstatOSErrorpopst_sizest_mtime)r filenamesrsizemtimerfullnamerrrr r4s&     rc Cs|tvr$tt|dkr$t|d|r<|dr@|dr@gS|}zt|}Wntyf|}t||rzt|d}Wnt tfyYnD0|durgYSt|ddd| D|ft|<t|dYStj |rgYSt j D]`}ztj ||}Wnttfy*YqYn0zt|}WqbWqtyVYq0qgYSYn0z8t|}|}Wdn1s0YWntygYS0|r|d d s|d d 7<|j|j} } | | ||ft|<|S) 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<>rcSsg|] }|dqS) r).0linerrr pzupdatecache..rr$)rr r startswithendswithrrrr ImportError splitlinespathisabssysjoin TypeErrorAttributeErrortokenizeopen readlinesrr) rrr!rbasenamedatadirnamefprrr rrr rPs\        , rcCs|tvr tt|dkrdSdS|r8|dr<|drs   C