B \]@sndZddlZddlZddlZddlZdddgZdddZiaddZddd Z dd dZ dd d Z d dZ 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. Ngetline clearcache checkcachecCs:t||}d|kr"t|kr2nn ||dSdSdS)N)getlineslen)filenamelinenomodule_globalslinesr %/usr/local/lib/python3.7/linecache.pyrs  cCsiadS)zClear the cache entirely.N)cacher r r rrscCsR|tkr(t|}t|dkr(t|dSy t||Stk rLtgSXdS)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.rN)rr updatecache MemoryErrorr)r r entryr r rr%s   rc Cs|dkrtt}n|tkr&|g}ndSx~|D]v}t|}t|dkrJq0|\}}}}|dkr`q0yt|}Wntk rt|=w0YnX||jks||jkr0t|=q0WdS)zUDiscard cache entries that are out of date. (This is not checked upon each call!)Nr) listrkeysrosstatOSErrorst_sizest_mtime)r Z filenamesrsizemtimer fullnamerr r rr5s&   c Cs|tkrtt|dkrt|=|r6|dr:|dr:gS|}yt|}Wntk rT|}t||ryt|d}Wnttfk rYnrNcSsg|] }|dqS) r ).0liner r r qszupdatecache..rr )rr startswithendswithrrr lazycache ImportError splitlinespathisabssysjoin TypeErrorAttributeErrortokenizeopen readlinesrr) r r rrbasenamedatadirnamefpr rrr r rrRsV        rcCs|tkr tt|dkrdSdS|r8|dr<|drs     A