Yf@sdZddlZddlZddlZddlZdddgZdddZiaddZddd 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 checkcachecCsEt||}d|ko,t|knr=||dSdSdS)N)getlineslen)filenamelinenomodule_globalslinesr ./opt/alt/python35/lib64/python3.5/linecache.pyrs" cCs iadS)zClear the cache entirely.N)cacher r r rrsc Csi|tkr4t|}t|dkr4t|dSyt||SWntk rdtgSYnXdS)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|dkr!ttj}n|tkr9|g}ndSx|D]}t|}t|dkriqD|\}}}}|dkrqDytj|}Wntk rt|=wDYnX||jks||jkrDt|=qDWdS)zUDiscard cache entries that are out of date. (This is not checked upon each call!)Nr) listrkeysrosstatOSErrorst_sizest_mtime)r filenamesrsizemtimer fullnamerr r rr5s&       c "Cs5|tkr)tt|dkr)t|=| sN|jdrR|jdrRgS|}ytj|}Wn0tk r|}t||r yt|d}Wnttfk rYnLX|dkrgSt|ddd|j D|ft|rNcSsg|]}|dqS) r ).0liner r r qs zupdatecache..rr!r%)rr startswithendswithrrr lazycache ImportError splitlinespathisabssysjoin TypeErrorAttributeErrortokenizeopen readlinesrr) r r rrbasenamedatadirnamefpr rrr r rrRsV %   #      rcCs|tkr*tt|dkr&dSdS| sO|jdrS|jdrSdS|rd|kr|jd}|d}t|dd }|r|rtj||}|ft|s      A